Skip to content

Commit b25bbf7

Browse files
committed
[SPARK-1406] Added export of pmml to distributed file system using the
spark context
1 parent 7a949d0 commit b25bbf7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mllib/src/main/scala/org/apache/spark/mllib/pmml/PMMLExportable.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ import java.io.OutputStream
2222
import java.io.StringWriter
2323
import javax.xml.transform.stream.StreamResult
2424
import org.jpmml.model.JAXBUtil
25+
import org.apache.spark.SparkContext
2526
import org.apache.spark.mllib.pmml.export.PMMLModelExport
2627
import org.apache.spark.mllib.pmml.export.PMMLModelExportFactory
2728

2829
/**
2930
* Export model to the PMML format
30-
* Predictive Model Markup Language (PMML) in an XML-based file format
31+
* Predictive Model Markup Language (PMML) is an XML-based file format
3132
* developed by the Data Mining Group (www.dmg.org).
3233
*/
3334
trait PMMLExportable {
@@ -47,6 +48,14 @@ trait PMMLExportable {
4748
toPMML(new StreamResult(new File(localPath)))
4849
}
4950

51+
/**
52+
* Export the model to a distributed file in PMML format
53+
*/
54+
def toPMML(sc: SparkContext, path: String): Unit = {
55+
val pmml = toPMML()
56+
sc.parallelize(Array(pmml),1).saveAsTextFile(path)
57+
}
58+
5059
/**
5160
* Export the model to the Outputtream in PMML format
5261
*/

0 commit comments

Comments
 (0)