Github user dbtsai commented on a diff in the pull request: https://github.com/apache/spark/pull/13796#discussion_r74679956 --- Diff: mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala --- @@ -966,10 +1102,26 @@ private class LogisticAggregator( instance: Instance, coefficients: Vector, featuresStd: Array[Double]): this.type = { + val numFeaturesPlusIntercept = if (fitIntercept) { + numFeatures + 1 + } else { + numFeatures + } instance match { case Instance(label, weight, features) => - require(numFeatures == features.size, s"Dimensions mismatch when adding new instance." + - s" Expecting $numFeatures but got ${features.size}.") + val size = coefficients.size + require(numFeatures == features.size, s"Dimension mismatch when adding new instance." + + s" Expecting $numFeatures but got ${features.size}") require(weight >= 0.0, s"instance weight, $weight has to be >= 0.0") + if (multinomial) { + require(numClasses == size / numFeaturesPlusIntercept, s"The number" + + s" of coefficients should be ${numClasses * numFeaturesPlusIntercept} but " + + s"was $size") + } else { + require(size == numFeaturesPlusIntercept, s"Expected " + --- End diff -- Do we need to check it for every instance? Will checking `numFeatures == features.size` be sufficient?
--- 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