Skip to content
Snippets Groups Projects
Commit bcecd73f authored by Dariusz Kobylarz's avatar Dariusz Kobylarz Committed by Xiangrui Meng
Browse files

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
parent e4f42631
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment