File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
mllib/src/main/scala/org/apache/spark/ml/classification Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -609,9 +609,14 @@ class LogisticRegression @Since("1.2.0") (
609609 Friedman, et al. "Regularization Paths for Generalized Linear Models via
610610 Coordinate Descent," https://core.ac.uk/download/files/153/6287975.pdf
611611 */
612- val denseValues = denseCoefficientMatrix.values
613- val coefficientMean = denseValues.sum / denseValues.length
614- denseCoefficientMatrix.update(_ - coefficientMean)
612+ val centers = Array .fill(numFeatures)(0.0 )
613+ denseCoefficientMatrix.foreachActive { case (i, j, v) =>
614+ centers(j) += v
615+ }
616+ centers.transform(_ / numCoefficientSets)
617+ denseCoefficientMatrix.foreachActive { case (i, j, v) =>
618+ denseCoefficientMatrix.update(i, j, v - centers(j))
619+ }
615620 }
616621
617622 // center the intercepts when using multinomial algorithm
You can’t perform that action at this time.
0 commit comments