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

    https://github.com/apache/spark/pull/4087#discussion_r25727333
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala ---
    @@ -35,26 +52,27 @@ import org.apache.spark.sql.{DataFrame, SQLContext}
      * @param pi log of class priors, whose dimension is C, number of labels
      * @param theta log of class conditional probabilities, whose dimension is 
C-by-D,
      *              where D is number of features
    + * @param modelType The type of NB model to fit from the enumeration 
NaiveBayesModels, can be
    + *              Multinomial or Bernoulli
      */
    +
     class NaiveBayesModel private[mllib] (
         val labels: Array[Double],
         val pi: Array[Double],
    -    val theta: Array[Array[Double]]) extends ClassificationModel with 
Serializable with Saveable {
    +    val theta: Array[Array[Double]],
    +    val modelType: NaiveBayesModels) extends ClassificationModel with 
Serializable with Saveable {
    +
    +  def this(labels: Array[Double], pi: Array[Double], theta: 
Array[Array[Double]]) =
    +    this(labels, pi, theta, NaiveBayesModels.Multinomial)
     
       private val brzPi = new BDV[Double](pi)
    -  private val brzTheta = new BDM[Double](theta.length, theta(0).length)
    +  private val brzTheta = new BDM(theta(0).length, theta.length, 
theta.flatten).t
     
    -  {
    -    // Need to put an extra pair of braces to prevent Scala treating `i` 
as a member.
    -    var i = 0
    -    while (i < theta.length) {
    -      var j = 0
    -      while (j < theta(i).length) {
    -        brzTheta(i, j) = theta(i)(j)
    -        j += 1
    -      }
    -      i += 1
    -    }
    +  private val brzNegTheta: Option[BDM[Double]] = modelType match {
    --- End diff --
    
    document please


---
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

Reply via email to