Repository: spark
Updated Branches:
  refs/heads/master ea3d2eed9 -> dc4abd4dc


[SPARK-6252] [mllib] Added getLambda to Scala NaiveBayes

Note: not relevant for Python API since it only has a static train method

Author: Joseph K. Bradley <joseph.kurata.brad...@gmail.com>
Author: Joseph K. Bradley <jos...@databricks.com>

Closes #4969 from jkbradley/SPARK-6252 and squashes the following commits:

a471d90 [Joseph K. Bradley] small edits from review
63eff48 [Joseph K. Bradley] Added getLambda to Scala NaiveBayes


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

Branch: refs/heads/master
Commit: dc4abd4dc40deacab39bfa9572b06bf0ea6daa6d
Parents: ea3d2ee
Author: Joseph K. Bradley <joseph.kurata.brad...@gmail.com>
Authored: Fri Mar 13 10:26:09 2015 -0700
Committer: Xiangrui Meng <m...@databricks.com>
Committed: Fri Mar 13 10:26:09 2015 -0700

----------------------------------------------------------------------
 .../org/apache/spark/mllib/classification/NaiveBayes.scala   | 3 +++
 .../apache/spark/mllib/classification/NaiveBayesSuite.scala  | 8 ++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/dc4abd4d/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala 
b/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala
index b11fd4f..2ebc7fa 100644
--- 
a/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala
+++ 
b/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala
@@ -166,6 +166,9 @@ class NaiveBayes private (private var lambda: Double) 
extends Serializable with
     this
   }
 
+  /** Get the smoothing parameter. Default: 1.0. */
+  def getLambda: Double = lambda
+
   /**
    * Run the algorithm with the configured parameters on an input RDD of 
LabeledPoint entries.
    *

http://git-wip-us.apache.org/repos/asf/spark/blob/dc4abd4d/mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
 
b/mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
index 64dcc0f..5a27c7d 100644
--- 
a/mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
+++ 
b/mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
@@ -85,6 +85,14 @@ class NaiveBayesSuite extends FunSuite with 
MLlibTestSparkContext {
     assert(numOfPredictions < input.length / 5)
   }
 
+  test("get, set params") {
+    val nb = new NaiveBayes()
+    nb.setLambda(2.0)
+    assert(nb.getLambda === 2.0)
+    nb.setLambda(3.0)
+    assert(nb.getLambda === 3.0)
+  }
+
   test("Naive Bayes") {
     val nPoints = 10000
 


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

Reply via email to