Skip to content

Commit f46c75c

Browse files
committed
[SPARK-1406] Added PMMLExportable to supported models
1 parent 7b33b4e commit f46c75c

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.apache.spark.mllib.classification.impl.GLMClassificationModel
2323
import org.apache.spark.mllib.linalg.BLAS.dot
2424
import org.apache.spark.mllib.linalg.{DenseVector, Vector}
2525
import org.apache.spark.mllib.optimization._
26+
import org.apache.spark.mllib.pmml.PMMLExportable
2627
import org.apache.spark.mllib.regression._
2728
import org.apache.spark.mllib.util.{DataValidators, Saveable, Loader}
2829
import org.apache.spark.rdd.RDD
@@ -46,7 +47,7 @@ class LogisticRegressionModel (
4647
val numFeatures: Int,
4748
val numClasses: Int)
4849
extends GeneralizedLinearModel(weights, intercept) with ClassificationModel with Serializable
49-
with Saveable {
50+
with Saveable with PMMLExportable {
5051

5152
if (numClasses == 2) {
5253
require(weights.size == numFeatures,

mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.apache.spark.annotation.Experimental
2222
import org.apache.spark.mllib.classification.impl.GLMClassificationModel
2323
import org.apache.spark.mllib.linalg.Vector
2424
import org.apache.spark.mllib.optimization._
25+
import org.apache.spark.mllib.pmml.PMMLExportable
2526
import org.apache.spark.mllib.regression._
2627
import org.apache.spark.mllib.util.{DataValidators, Saveable, Loader}
2728
import org.apache.spark.rdd.RDD
@@ -37,7 +38,7 @@ class SVMModel (
3738
override val weights: Vector,
3839
override val intercept: Double)
3940
extends GeneralizedLinearModel(weights, intercept) with ClassificationModel with Serializable
40-
with Saveable {
41+
with Saveable with PMMLExportable {
4142

4243
private var threshold: Option[Double] = Some(0.0)
4344

mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeansModel.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import org.apache.spark.api.java.JavaRDD
2121
import org.apache.spark.rdd.RDD
2222
import org.apache.spark.SparkContext._
2323
import org.apache.spark.mllib.linalg.Vector
24+
import org.apache.spark.mllib.pmml.PMMLExportable
2425

2526
/**
2627
* A clustering model for K-means. Each point belongs to the cluster with the closest center.
2728
*/
28-
class KMeansModel (val clusterCenters: Array[Vector]) extends Serializable {
29+
class KMeansModel (val clusterCenters: Array[Vector]) extends Serializable with PMMLExportable {
2930

3031
/** Total number of clusters. */
3132
def k: Int = clusterCenters.length

mllib/src/main/scala/org/apache/spark/mllib/regression/Lasso.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.spark.mllib.regression
2020
import org.apache.spark.SparkContext
2121
import org.apache.spark.mllib.linalg.Vector
2222
import org.apache.spark.mllib.optimization._
23+
import org.apache.spark.mllib.pmml.PMMLExportable
2324
import org.apache.spark.mllib.regression.impl.GLMRegressionModel
2425
import org.apache.spark.mllib.util.{Saveable, Loader}
2526
import org.apache.spark.rdd.RDD
@@ -34,7 +35,7 @@ class LassoModel (
3435
override val weights: Vector,
3536
override val intercept: Double)
3637
extends GeneralizedLinearModel(weights, intercept)
37-
with RegressionModel with Serializable with Saveable {
38+
with RegressionModel with Serializable with Saveable with PMMLExportable {
3839

3940
override protected def predictPoint(
4041
dataMatrix: Vector,

mllib/src/main/scala/org/apache/spark/mllib/regression/LinearRegression.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.spark.mllib.regression
2020
import org.apache.spark.SparkContext
2121
import org.apache.spark.mllib.linalg.Vector
2222
import org.apache.spark.mllib.optimization._
23+
import org.apache.spark.mllib.pmml.PMMLExportable
2324
import org.apache.spark.mllib.regression.impl.GLMRegressionModel
2425
import org.apache.spark.mllib.util.{Saveable, Loader}
2526
import org.apache.spark.rdd.RDD
@@ -34,7 +35,7 @@ class LinearRegressionModel (
3435
override val weights: Vector,
3536
override val intercept: Double)
3637
extends GeneralizedLinearModel(weights, intercept) with RegressionModel with Serializable
37-
with Saveable {
38+
with Saveable with PMMLExportable {
3839

3940
override protected def predictPoint(
4041
dataMatrix: Vector,

mllib/src/main/scala/org/apache/spark/mllib/regression/RidgeRegression.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.spark.mllib.regression
2020
import org.apache.spark.SparkContext
2121
import org.apache.spark.mllib.linalg.Vector
2222
import org.apache.spark.mllib.optimization._
23+
import org.apache.spark.mllib.pmml.PMMLExportable
2324
import org.apache.spark.mllib.regression.impl.GLMRegressionModel
2425
import org.apache.spark.mllib.util.{Loader, Saveable}
2526
import org.apache.spark.rdd.RDD
@@ -35,7 +36,7 @@ class RidgeRegressionModel (
3536
override val weights: Vector,
3637
override val intercept: Double)
3738
extends GeneralizedLinearModel(weights, intercept)
38-
with RegressionModel with Serializable with Saveable {
39+
with RegressionModel with Serializable with Saveable with PMMLExportable {
3940

4041
override protected def predictPoint(
4142
dataMatrix: Vector,

0 commit comments

Comments
 (0)