Repository: spark
Updated Branches:
  refs/heads/master 3c4e486b9 -> dda4dedca


[SPARK-6291] [MLLIB] GLM toString & toDebugString

GLM toString prints out intercept, numFeatures.
For LogisticRegression and SVM model, toString also prints out numClasses, 
threshold.
GLM toDebugString prints out the whole weights, intercept.

Author: Yanbo Liang <yblia...@gmail.com>

Closes #5038 from yanboliang/spark-6291 and squashes the following commits:

2f578b0 [Yanbo Liang] code format
78b33f2 [Yanbo Liang] fix typos
1e8a023 [Yanbo Liang] GLM toString & toDebugString


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/dda4dedc
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/dda4dedc
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/dda4dedc

Branch: refs/heads/master
Commit: dda4dedca0459fc7c00eb1d9cb07e14af1621e0f
Parents: 3c4e486
Author: Yanbo Liang <yblia...@gmail.com>
Authored: Thu Mar 19 11:10:20 2015 -0400
Committer: Sean Owen <so...@cloudera.com>
Committed: Thu Mar 19 11:10:20 2015 -0400

----------------------------------------------------------------------
 .../spark/mllib/classification/LogisticRegression.scala       | 4 ++++
 .../scala/org/apache/spark/mllib/classification/SVM.scala     | 4 ++++
 .../spark/mllib/regression/GeneralizedLinearAlgorithm.scala   | 7 ++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/dda4dedc/mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
 
b/mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
index b787667..e7c3599 100644
--- 
a/mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
+++ 
b/mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
@@ -163,6 +163,10 @@ class LogisticRegressionModel (
   }
 
   override protected def formatVersion: String = "1.0"
+
+  override def toString: String = {
+    s"${super.toString}, numClasses = ${numClasses}, threshold = 
${threshold.get}"
+  }
 }
 
 object LogisticRegressionModel extends Loader[LogisticRegressionModel] {

http://git-wip-us.apache.org/repos/asf/spark/blob/dda4dedc/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala 
b/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala
index cfc7f86..52fb62d 100644
--- a/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala
+++ b/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala
@@ -86,6 +86,10 @@ class SVMModel (
   }
 
   override protected def formatVersion: String = "1.0"
+
+  override def toString: String = {
+    s"${super.toString}, numClasses = 2, threshold = ${threshold.get}"
+  }
 }
 
 object SVMModel extends Loader[SVMModel] {

http://git-wip-us.apache.org/repos/asf/spark/blob/dda4dedc/mllib/src/main/scala/org/apache/spark/mllib/regression/GeneralizedLinearAlgorithm.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/mllib/regression/GeneralizedLinearAlgorithm.scala
 
b/mllib/src/main/scala/org/apache/spark/mllib/regression/GeneralizedLinearAlgorithm.scala
index b262bec..45b9ebb 100644
--- 
a/mllib/src/main/scala/org/apache/spark/mllib/regression/GeneralizedLinearAlgorithm.scala
+++ 
b/mllib/src/main/scala/org/apache/spark/mllib/regression/GeneralizedLinearAlgorithm.scala
@@ -76,7 +76,12 @@ abstract class GeneralizedLinearModel(val weights: Vector, 
val intercept: Double
     predictPoint(testData, weights, intercept)
   }
 
-  override def toString() = "(weights=%s, intercept=%s)".format(weights, 
intercept)
+  /**
+   * Print a summary of the model.
+   */
+  override def toString: String = {
+    s"${this.getClass.getName}: intercept = ${intercept}, numFeatures = 
${weights.size}"
+  }
 }
 
 /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to