Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/13796#discussion_r74833711
--- 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 --
Nope. Those shouldn't have been in the add method. I moved them out.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]