Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/653#discussion_r12315475
  
    --- Diff: docs/mllib-naive-bayes.md ---
    @@ -58,29 +67,36 @@ optionally smoothing parameter `lambda` as input, and 
output a
     can be used for evaluation and prediction.
     
     {% highlight java %}
    +import org.apache.spark.api.java.JavaPairRDD;
    +import org.apache.spark.api.java.JavaRDD;
    +import org.apache.spark.api.java.function.Function;
     import org.apache.spark.mllib.classification.NaiveBayes;
    +import org.apache.spark.mllib.classification.NaiveBayesModel;
    +import org.apache.spark.mllib.regression.LabeledPoint;
    +import scala.Tuple2;
     
     JavaRDD<LabeledPoint> training = ... // training set
     JavaRDD<LabeledPoint> test = ... // test set
     
    -NaiveBayesModel model = NaiveBayes.train(training.rdd(), 1.0);
    +final NaiveBayesModel model = NaiveBayes.train(training.rdd(), 1.0);
     
    -JavaRDD<Double> prediction = model.predict(test.map(new 
Function<LabeledPoint, Vector>() {
    --- End diff --
    
    Aha, can you help me with a hint? I didn't realize that an `RDD[Double]` 
isn't magically an `RDD<Double>` in Java. The Java signature of the `predict()` 
method already ends up at `RDD<Object>`, and Java casting doesn't help. I don't 
believe I want to change the method. (Which incidentally just does the same 
operation I 'inlined' into this example, which works. Hm.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to