Skip to content

Commit 8fb0877

Browse files
dding3mengxr
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 <dingding@dingding-ubuntu.sh.intel.com> Closes #12948 from dding3/master. (cherry picked from commit a78fbfa) Signed-off-by: Xiangrui Meng <meng@databricks.com>
1 parent 47feebd commit 8fb0877

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
@@ -367,9 +367,10 @@ class LogisticRegression @Since("1.2.0") (
367367
Vectors.zeros(if ($(fitIntercept)) numFeatures + 1 else numFeatures)
368368

369369
if (optInitialModel.isDefined && optInitialModel.get.coefficients.size != numFeatures) {
370-
val vec = optInitialModel.get.coefficients
370+
val vecSize = optInitialModel.get.coefficients.size
371371
logWarning(
372-
s"Initial coefficients provided $vec did not match the expected size $numFeatures")
372+
s"Initial coefficients will be ignored!! As its size $vecSize did not match the " +
373+
s"expected size $numFeatures")
373374
}
374375

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

0 commit comments

Comments
 (0)