title: Spark: How to get probabilities and AUC for Bernoulli Naive Bayes?
body: <p>I'm running a <code>Bernoulli Naive Bayes</code> using code:</p>
  
  
  
  <pre><code>val splits = MyData.randomSplit(Array(0.75, 0.25), seed = 2L)
  val training = splits(0).cache()
  val test = splits(1)
  val model = NaiveBayes.train(training, lambda = 3.0, modelType = "bernoulli")
  </code></pre>
  
  <p>My question is how can I get the probability of membership to class 0 (or 1) and count AUC. I want to get similar result to <code>LogisticRegressionWithSGD</code> or <code>SVMWithSGD</code> where I was using this code:</p>
  
   
  
  <pre><code>val numIterations = 100
  
  val model = SVMWithSGD.train(training, numIterations)
  model.clearThreshold()
  
  // Compute raw scores on the test set.
  val labelAndPreds = test.map { point =&gt;
        val prediction = model.predict(point.features)
        (prediction, point.label)
  }
  
  // Get evaluation metrics.
  val metrics = new BinaryClassificationMetrics(labelAndPreds)
  val auROC = metrics.areaUnderROC() 
  </code></pre>
  
  <p>Unfortunately this code isn't working for <code>NaiveBayes</code>.</p>