Skip to content

Commit

Permalink
[SPARK-1406] Added Double Min and Max
Browse files Browse the repository at this point in the history
Fixed scala style
  • Loading branch information
selvinsource committed Apr 29, 2015
1 parent 30165c4 commit 085cf42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ private[mllib] class BinaryClassificationPMMLModelExport(
val regressionTableYES = new RegressionTable(model.intercept).withTargetCategory("1")
var interceptNO = threshold
if (RegressionNormalizationMethodType.LOGIT == normalizationMethod) {
if (threshold <= 0)
interceptNO = -1000
else if (threshold >= 1)
interceptNO = 1000
else
interceptNO = -math.log(1/threshold -1)
if (threshold <= 0) {
interceptNO = Double.MinValue
} else if (threshold >= 1) {
interceptNO = Double.MaxValue
} else {
interceptNO = -math.log(1 / threshold - 1)
}
}
val regressionTableNO = new RegressionTable(interceptNO).withTargetCategory("0")
val regressionModel = new RegressionModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ private[mllib] object PMMLModelExportFactory {
svm, "linear SVM", RegressionNormalizationMethodType.NONE,
svm.getThreshold.getOrElse(0.0))
case logistic: LogisticRegressionModel =>
if (logistic.numClasses == 2)
if (logistic.numClasses == 2) {
new BinaryClassificationPMMLModelExport(
logistic, "logistic regression", RegressionNormalizationMethodType.LOGIT,
logistic.getThreshold.getOrElse(0.5))
else
} else {
throw new IllegalArgumentException(
"PMML Export not supported for Multinomial Logistic Regression")
}
case _ =>
throw new IllegalArgumentException(
"PMML Export not supported for model: " + model.getClass.getName)
Expand Down

0 comments on commit 085cf42

Please sign in to comment.