Skip to content

Commit 494b632

Browse files
committed
compure score once
1 parent ad678e9 commit 494b632

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,10 @@ class LogisticRegressionModel private[ml] (
128128
1.0 / (1.0 + math.exp(-margin))
129129
}
130130
val t = map(threshold)
131-
val predict: Vector => Double = (v) => {
132-
if (score(v) > t) 1.0 else 0.0
131+
val predict: Double => Double = (score) => {
132+
if (score > t) 1.0 else 0.0
133133
}
134-
dataset.select(
135-
Star(None),
136-
score.call(map(featuresCol).attr) as map(scoreCol),
137-
predict.call(map(featuresCol).attr) as map(predictionCol))
134+
dataset.select(Star(None), score.call(map(featuresCol).attr) as map(scoreCol))
135+
.select(Star(None), predict.call(map(scoreCol).attr) as map(predictionCol))
138136
}
139137
}

0 commit comments

Comments
 (0)