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_r344430184
########## File path: mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala ########## @@ -396,15 +545,29 @@ object NaiveBayesModel extends MLReadable[NaiveBayesModel] { private val className = classOf[NaiveBayesModel].getName override def load(path: String): NaiveBayesModel = { + implicit val format = DefaultFormats val metadata = DefaultParamsReader.loadMetadata(path, sc, className) + val (major, minor) = VersionUtils.majorMinorVersion(metadata.sparkVersion) + val modelTypeJson = metadata.getParamValue("modelType") + val modelType = Param.jsonDecode[String](compact(render(modelTypeJson))) val dataPath = new Path(path, "data").toString val data = sparkSession.read.parquet(dataPath) val vecConverted = MLUtils.convertVectorColumnsToML(data, "pi") - val Row(pi: Vector, theta: Matrix) = MLUtils.convertMatrixColumnsToML(vecConverted, "theta") - .select("pi", "theta") - .head() - val model = new NaiveBayesModel(metadata.uid, pi, theta) + + val model = if (major.toInt < 3 || modelType != NaiveBayes.Gaussian) { Review comment: yes, it is also used in: [LogisticRegressionModel](https://github.com/apache/spark/blob/5853e8b3301fd7b0bff721d5a47139afb17bfd2b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala#L1229) [HashingTF](https://github.com/apache/spark/blob/4664a082c2c7ac989e818958c465c72833d3ccfe/mllib/src/main/scala/org/apache/spark/ml/feature/HashingTF.scala#L147) [LinearRegressionModel](https://github.com/apache/spark/blob/5853e8b3301fd7b0bff721d5a47139afb17bfd2b/mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala#L769) and so on ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org