[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 <ybliang8@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
This commit is contained in:
Yanbo Liang 2015-03-19 11:10:20 -04:00 committed by Sean Owen
parent 3c4e486b9c
commit dda4dedca0
3 changed files with 14 additions and 1 deletions

View file

@ -163,6 +163,10 @@ class LogisticRegressionModel (
} }
override protected def formatVersion: String = "1.0" override protected def formatVersion: String = "1.0"
override def toString: String = {
s"${super.toString}, numClasses = ${numClasses}, threshold = ${threshold.get}"
}
} }
object LogisticRegressionModel extends Loader[LogisticRegressionModel] { object LogisticRegressionModel extends Loader[LogisticRegressionModel] {

View file

@ -86,6 +86,10 @@ class SVMModel (
} }
override protected def formatVersion: String = "1.0" override protected def formatVersion: String = "1.0"
override def toString: String = {
s"${super.toString}, numClasses = 2, threshold = ${threshold.get}"
}
} }
object SVMModel extends Loader[SVMModel] { object SVMModel extends Loader[SVMModel] {

View file

@ -76,7 +76,12 @@ abstract class GeneralizedLinearModel(val weights: Vector, val intercept: Double
predictPoint(testData, weights, intercept) 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}"
}
} }
/** /**