Skip to content

Commit a78fbfa

Browse files
dding3srowen
authored andcommitted
[SPARK-15172][ML] Explicitly tell user initial coefficients is ignored when size mismatch happened in LogisticRegression
## What changes were proposed in this pull request? Explicitly tell user initial coefficients is ignored if its size doesn't match expected size in LogisticRegression ## How was this patch tested? local build Author: dding3 <[email protected]> Closes apache#12948 from dding3/master.
1 parent 12fe2ec commit a78fbfa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,10 @@ class LogisticRegression @Since("1.2.0") (
366366
Vectors.zeros(if ($(fitIntercept)) numFeatures + 1 else numFeatures)
367367

368368
if (optInitialModel.isDefined && optInitialModel.get.coefficients.size != numFeatures) {
369-
val vec = optInitialModel.get.coefficients
369+
val vecSize = optInitialModel.get.coefficients.size
370370
logWarning(
371-
s"Initial coefficients provided $vec did not match the expected size $numFeatures")
371+
s"Initial coefficients will be ignored!! As its size $vecSize did not match the " +
372+
s"expected size $numFeatures")
372373
}
373374

374375
if (optInitialModel.isDefined && optInitialModel.get.coefficients.size == numFeatures) {

0 commit comments

Comments
 (0)