Skip to content

Commit bcecd73

Browse files
dkobylarzmengxr
authored andcommitted
fixed MLlib Naive-Bayes java example bug
the filter tests Double objects by references whereas it should test their values Author: Dariusz Kobylarz <[email protected]> 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
1 parent e4f4263 commit bcecd73

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/mllib-naive-bayes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ JavaPairRDD<Double, Double> predictionAndLabel =
8888
return new Tuple2<Double, Double>(model.predict(p.features()), p.label());
8989
}
9090
});
91-
double accuracy = 1.0 * predictionAndLabel.filter(new Function<Tuple2<Double, Double>, Boolean>() {
91+
double accuracy = predictionAndLabel.filter(new Function<Tuple2<Double, Double>, Boolean>() {
9292
@Override public Boolean call(Tuple2<Double, Double> pl) {
93-
return pl._1() == pl._2();
93+
return pl._1().equals(pl._2());
9494
}
95-
}).count() / test.count();
95+
}).count() / (double) test.count();
9696
{% endhighlight %}
9797
</div>
9898

0 commit comments

Comments
 (0)