Repository: spark
Updated Branches:
  refs/heads/branch-1.4 2a42d2d8f -> 0b6bc8a23


[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 <[email protected]>

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 <[email protected]>


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

Branch: refs/heads/branch-1.4
Commit: 0b6bc8a2394a26203d7be9ab53cc9dc5970d41a6
Parents: 2a42d2d
Author: Shuo Xiang <[email protected]>
Authored: Sun May 17 21:16:52 2015 -0700
Committer: Xiangrui Meng <[email protected]>
Committed: Sun May 17 21:16:59 2015 -0700

----------------------------------------------------------------------
 .../org/apache/spark/mllib/classification/LogisticRegression.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/0b6bc8a2/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 bd2e907..2df4d21 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")}"
   }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to