aboutsummaryrefslogtreecommitdiff
path: root/mllib
diff options
context:
space:
mode:
authorShuo Xiang <shuoxiangpub@gmail.com>2015-05-17 21:16:52 -0700
committerXiangrui Meng <meng@databricks.com>2015-05-17 21:16:52 -0700
commit775e6f9909d4495cbc11c377508b43482d782742 (patch)
tree5b1002e840851a54fd22024c18ff7ae1525cc386 /mllib
parentff71d34e00b64d70f671f9bf3e63aec39cd525e5 (diff)
downloadspark-775e6f9909d4495cbc11c377508b43482d782742.tar.gz
spark-775e6f9909d4495cbc11c377508b43482d782742.tar.bz2
spark-775e6f9909d4495cbc11c377508b43482d782742.zip
[SPARK-7694] [MLLIB] Use getOrElse for getting the threshold of LR model
The `toString` method of `LogisticRegressionModel` calls `get` method on an Option (threshold) without a safeguard. In spark-shell, the following code `val model = algorithm.run(data).clearThreshold()` in lbfgs code will fail as `toString `method will be called right after `clearThreshold()` to show the results in the REPL. Author: Shuo Xiang <shuoxiangpub@gmail.com> Closes #6224 from coderxiang/getorelse and squashes the following commits: d5f53c9 [Shuo Xiang] use getOrElse for getting the threshold of LR model 5f109b4 [Shuo Xiang] Merge remote-tracking branch 'upstream/master' c5c5bfe [Shuo Xiang] Merge remote-tracking branch 'upstream/master' 98804c9 [Shuo Xiang] fix bug in topBykey and update test
Diffstat (limited to 'mllib')
-rw-r--r--mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala2
1 files changed, 1 insertions, 1 deletions
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 bd2e9079ce..2df4d21e8c 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,7 +163,7 @@ class LogisticRegressionModel (
override protected def formatVersion: String = "1.0"
override def toString: String = {
- s"${super.toString}, numClasses = ${numClasses}, threshold = ${threshold.get}"
+ s"${super.toString}, numClasses = ${numClasses}, threshold = ${threshold.getOrElse("None")}"
}
}