Skip to content

Commit

Permalink
[SPARK-1406] Added export of pmml to distributed file system using the
Browse files Browse the repository at this point in the history
spark context
  • Loading branch information
selvinsource committed Mar 1, 2015
1 parent 7a949d0 commit b25bbf7
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import java.io.OutputStream
import java.io.StringWriter
import javax.xml.transform.stream.StreamResult
import org.jpmml.model.JAXBUtil
import org.apache.spark.SparkContext
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
* Predictive Model Markup Language (PMML) is an XML-based file format
* developed by the Data Mining Group (www.dmg.org).
*/
trait PMMLExportable {
Expand All @@ -47,6 +48,14 @@ trait PMMLExportable {
toPMML(new StreamResult(new File(localPath)))
}

/**
* Export the model to a distributed file in PMML format
*/
def toPMML(sc: SparkContext, path: String): Unit = {
val pmml = toPMML()
sc.parallelize(Array(pmml),1).saveAsTextFile(path)
}

/**
* Export the model to the Outputtream in PMML format
*/
Expand Down

0 comments on commit b25bbf7

Please sign in to comment.