Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/6761#discussion_r32417054 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala --- @@ -113,6 +106,55 @@ class NaiveBayesModel private[mllib] ( } } + def predictProbabilities(testData: RDD[Vector]): RDD[Map[Double, Double]] = { + val bcModel = testData.context.broadcast(this) + testData.mapPartitions { iter => + val model = bcModel.value + iter.map(model.predictProbabilities) + } + } + + def predictProbabilities(testData: Vector): Map[Double, Double] = { + modelType match { + case Multinomial => + val prob = multinomialCalculation(testData) + posteriorProbabilities(prob) + case Bernoulli => + val prob = bernoulliCalculation(testData) + posteriorProbabilities(prob) + case _ => --- End diff -- Will this generate a compiler warning without this case or does it already prove there aren't other possibilities? in which case I think you can let it produce a match error if it ever somehow hits that case. `UnknownError` seems to strong as it's at best an `IllegalStateException` or something, not a VM error.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org