forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-1406] Added a PMMLExportable interface
Restructured code in a new package mllib.pmml Supported models implements the new PMMLExportable interface: LogisticRegression, SVM, KMeansModel, LinearRegression, RidgeRegression, Lasso
- Loading branch information
1 parent
d559ec5
commit 7b33b4e
Showing
13 changed files
with
110 additions
and
168 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
mllib/src/main/scala/org/apache/spark/mllib/export/ModelExport.scala
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
mllib/src/main/scala/org/apache/spark/mllib/export/ModelExportType.scala
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
mllib/src/main/scala/org/apache/spark/mllib/export/ModelExporter.scala
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
mllib/src/main/scala/org/apache/spark/mllib/pmml/PMMLExportable.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.mllib.pmml | ||
|
||
import java.io.File | ||
import java.io.OutputStream | ||
import java.io.StringWriter | ||
import javax.xml.transform.stream.StreamResult | ||
import org.jpmml.model.JAXBUtil | ||
import org.apache.spark.mllib.pmml.export.PMMLModelExport | ||
import org.apache.spark.mllib.pmml.export.PMMLModelExportFactory | ||
|
||
/** | ||
* Export model to the PMML format | ||
* Predictive Model Markup Language (PMML) in an XML-based file format | ||
* developed by the Data Mining Group (www.dmg.org). | ||
*/ | ||
trait PMMLExportable { | ||
|
||
/** | ||
* Export the model to the stream result in PMML format | ||
*/ | ||
private def toPMML(streamResult: StreamResult): Unit = { | ||
val pmmlModelExport = PMMLModelExportFactory.createPMMLModelExport(this) | ||
JAXBUtil.marshalPMML(pmmlModelExport.getPmml(), streamResult) | ||
} | ||
|
||
/** | ||
* Export the model to a local File in PMML format | ||
*/ | ||
def toPMML(localPath: String): Unit = { | ||
toPMML(new StreamResult(new File(localPath))) | ||
} | ||
|
||
/** | ||
* Export the model to the Outputtream in PMML format | ||
*/ | ||
def toPMML(outputStream: OutputStream): Unit = { | ||
toPMML(new StreamResult(outputStream)) | ||
} | ||
|
||
/** | ||
* Export the model to a String in PMML format | ||
*/ | ||
def toPMML(): String = { | ||
var writer = new StringWriter(); | ||
toPMML(new StreamResult(writer)) | ||
return writer.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.