spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] zhengruifeng commented on a change in pull request #26413: [SPARK-16872][ML][PYSPARK] Impl Gaussian Naive Bayes Classifier
Date Sat, 09 Nov 2019 05:24:46 GMT
zhengruifeng commented on a change in pull request #26413: [SPARK-16872][ML][PYSPARK] Impl
Gaussian Naive Bayes Classifier
URL: https://github.com/apache/spark/pull/26413#discussion_r344429910
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala
 ##########
 @@ -280,15 +381,35 @@ class NaiveBayesModel private[ml] (
    * This precomputes log(1.0 - exp(theta)) and its sum which are used for the linear algebra
    * application of this condition (in predict function).
    */
-  private lazy val (thetaMinusNegTheta, negThetaSum) = $(modelType) match {
-    case Multinomial => (None, None)
+  @transient private lazy val (thetaMinusNegTheta, negThetaSum) = $(modelType) match {
     case Bernoulli =>
       val negTheta = theta.map(value => math.log1p(-math.exp(value)))
       val ones = new DenseVector(Array.fill(theta.numCols) {1.0})
       val thetaMinusNegTheta = theta.map { value =>
         value - math.log1p(-math.exp(value))
       }
-      (Option(thetaMinusNegTheta), Option(negTheta.multiply(ones)))
+      (thetaMinusNegTheta, negTheta.multiply(ones))
+    case Multinomial => (null, null)
+    case Gaussian => (null, null)
 
 Review comment:
   I think causing an error is ok, avaliable `thetaMinusNegTheta, negThetaSum` should only
be referenced in Bernoulli case.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message