Skip to content

Commit 085cf42

Browse files
committed
[SPARK-1406] Added Double Min and Max
Fixed scala style
1 parent 30165c4 commit 085cf42

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

mllib/src/main/scala/org/apache/spark/mllib/pmml/export/BinaryClassificationPMMLModelExport.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ private[mllib] class BinaryClassificationPMMLModelExport(
4848
val regressionTableYES = new RegressionTable(model.intercept).withTargetCategory("1")
4949
var interceptNO = threshold
5050
if (RegressionNormalizationMethodType.LOGIT == normalizationMethod) {
51-
if (threshold <= 0)
52-
interceptNO = -1000
53-
else if (threshold >= 1)
54-
interceptNO = 1000
55-
else
56-
interceptNO = -math.log(1/threshold -1)
51+
if (threshold <= 0) {
52+
interceptNO = Double.MinValue
53+
} else if (threshold >= 1) {
54+
interceptNO = Double.MaxValue
55+
} else {
56+
interceptNO = -math.log(1 / threshold - 1)
57+
}
5758
}
5859
val regressionTableNO = new RegressionTable(interceptNO).withTargetCategory("0")
5960
val regressionModel = new RegressionModel()

mllib/src/main/scala/org/apache/spark/mllib/pmml/export/PMMLModelExportFactory.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ private[mllib] object PMMLModelExportFactory {
4747
svm, "linear SVM", RegressionNormalizationMethodType.NONE,
4848
svm.getThreshold.getOrElse(0.0))
4949
case logistic: LogisticRegressionModel =>
50-
if (logistic.numClasses == 2)
50+
if (logistic.numClasses == 2) {
5151
new BinaryClassificationPMMLModelExport(
5252
logistic, "logistic regression", RegressionNormalizationMethodType.LOGIT,
5353
logistic.getThreshold.getOrElse(0.5))
54-
else
54+
} else {
5555
throw new IllegalArgumentException(
5656
"PMML Export not supported for Multinomial Logistic Regression")
57+
}
5758
case _ =>
5859
throw new IllegalArgumentException(
5960
"PMML Export not supported for model: " + model.getClass.getName)

0 commit comments

Comments
 (0)