zhengruifeng commented on a change in pull request #26679: [SPARK-30044][ML] 
MNB/CNB/BNB use empty sigma matrix instead of null
URL: https://github.com/apache/spark/pull/26679#discussion_r351560577
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala
 ##########
 @@ -247,12 +246,12 @@ class NaiveBayes @Since("1.5.0") (
     $(modelType) match {
       case Multinomial | Bernoulli =>
         val theta = new DenseMatrix(numLabels, numFeatures, thetaArray, true)
-        new NaiveBayesModel(uid, pi.compressed, theta.compressed, null)
+        new NaiveBayesModel(uid, pi.compressed, theta.compressed, 
Matrices.zeros(0, 0))
 
 Review comment:
   In MNB/CNB/BNB, it is a empty matrix (numRows=0, numCols=0), so it should be 
tiny.
   In GNB, it is a matrix of size = #class x #feature , as big as `theta` 
matrix.
   I also test the backwards-compatibilty: save a model in 2.4.4, and load it 
in this PR, it works fine.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to