diff options
author | Dariusz Kobylarz <darek.kobylarz@gmail.com> | 2014-11-04 09:53:43 -0800 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2014-11-04 09:54:05 -0800 |
commit | 4b13bff939291caa1fb9b9a180db66b1d006153c (patch) | |
tree | 0c05de85b54be2102e52db6b31e7979132653306 /docs | |
parent | 786e75b33f0bc1445bfc289fe4b62407cb79026e (diff) | |
download | spark-4b13bff939291caa1fb9b9a180db66b1d006153c.tar.gz spark-4b13bff939291caa1fb9b9a180db66b1d006153c.tar.bz2 spark-4b13bff939291caa1fb9b9a180db66b1d006153c.zip |
fixed MLlib Naive-Bayes java example bug
the filter tests Double objects by references whereas it should test their values
Author: Dariusz Kobylarz <darek.kobylarz@gmail.com>
Closes #3081 from dkobylarz/master and squashes the following commits:
5d43a39 [Dariusz Kobylarz] naive bayes example update
a304b93 [Dariusz Kobylarz] fixed MLlib Naive-Bayes java example bug
(cherry picked from commit bcecd73fdd4d2ec209259cfd57d3ad1d63f028f2)
Signed-off-by: Xiangrui Meng <meng@databricks.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/mllib-naive-bayes.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/mllib-naive-bayes.md b/docs/mllib-naive-bayes.md index 7f9d4c6563..d5b044d94f 100644 --- a/docs/mllib-naive-bayes.md +++ b/docs/mllib-naive-bayes.md @@ -88,11 +88,11 @@ JavaPairRDD<Double, Double> predictionAndLabel = return new Tuple2<Double, Double>(model.predict(p.features()), p.label()); } }); -double accuracy = 1.0 * predictionAndLabel.filter(new Function<Tuple2<Double, Double>, Boolean>() { +double accuracy = predictionAndLabel.filter(new Function<Tuple2<Double, Double>, Boolean>() { @Override public Boolean call(Tuple2<Double, Double> pl) { - return pl._1() == pl._2(); + return pl._1().equals(pl._2()); } - }).count() / test.count(); + }).count() / (double) test.count(); {% endhighlight %} </div> |