diff options
author | Shuo Xiang <shuoxiangpub@gmail.com> | 2015-05-17 21:16:52 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2015-05-17 21:16:59 -0700 |
commit | 0b6bc8a2394a26203d7be9ab53cc9dc5970d41a6 (patch) | |
tree | 6cb7284a8e715c05a319b3cc36bfe9d34668e774 /mllib | |
parent | 2a42d2d8f26e3e66ab8c926e952a20a3900ca7f3 (diff) | |
download | spark-0b6bc8a2394a26203d7be9ab53cc9dc5970d41a6.tar.gz spark-0b6bc8a2394a26203d7be9ab53cc9dc5970d41a6.tar.bz2 spark-0b6bc8a2394a26203d7be9ab53cc9dc5970d41a6.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
(cherry picked from commit 775e6f9909d4495cbc11c377508b43482d782742)
Signed-off-by: Xiangrui Meng <meng@databricks.com>
Diffstat (limited to 'mllib')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala | 2 |
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")}" } } |