Skip to content
Snippets Groups Projects
Commit 2ad4837c authored by Xiangrui Meng's avatar Xiangrui Meng
Browse files

[SPARK-7537] [MLLIB] spark.mllib API updates

Minor updates to the spark.mllib APIs:

1. Add `DeveloperApi` to `PMMLExportable` and add `Experimental` to `toPMML` methods.
2. Mention `RankingMetrics.of` in the `RankingMetrics` constructor.

Author: Xiangrui Meng <meng@databricks.com>

Closes #6280 from mengxr/SPARK-7537 and squashes the following commits:

1bd2583 [Xiangrui Meng] organize imports
94afa7a [Xiangrui Meng] mark all toPMML methods experimental
4c40da1 [Xiangrui Meng] mention the factory method for RankingMetrics for Java users
88c62d0 [Xiangrui Meng] add DeveloperApi to PMMLExportable
parent b631bf73
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,8 @@ import org.apache.spark.rdd.RDD
* ::Experimental::
* Evaluator for ranking algorithms.
*
* Java users should use [[RankingMetrics$.of]] to create a [[RankingMetrics]] instance.
*
* @param predictionAndLabels an RDD of (predicted ranking, ground truth set) pairs.
*/
@Experimental
......
......@@ -23,13 +23,16 @@ import javax.xml.transform.stream.StreamResult
import org.jpmml.model.JAXBUtil
import org.apache.spark.SparkContext
import org.apache.spark.annotation.{DeveloperApi, Experimental}
import org.apache.spark.mllib.pmml.export.PMMLModelExportFactory
/**
* :: DeveloperApi ::
* Export model to the PMML format
* Predictive Model Markup Language (PMML) is an XML-based file format
* developed by the Data Mining Group (www.dmg.org).
*/
@DeveloperApi
trait PMMLExportable {
/**
......@@ -41,30 +44,38 @@ trait PMMLExportable {
}
/**
* :: Experimental ::
* Export the model to a local file in PMML format
*/
@Experimental
def toPMML(localPath: String): Unit = {
toPMML(new StreamResult(new File(localPath)))
}
/**
* :: Experimental ::
* Export the model to a directory on a distributed file system in PMML format
*/
@Experimental
def toPMML(sc: SparkContext, path: String): Unit = {
val pmml = toPMML()
sc.parallelize(Array(pmml), 1).saveAsTextFile(path)
}
/**
* :: Experimental ::
* Export the model to the OutputStream in PMML format
*/
@Experimental
def toPMML(outputStream: OutputStream): Unit = {
toPMML(new StreamResult(outputStream))
}
/**
* :: Experimental ::
* Export the model to a String in PMML format
*/
@Experimental
def toPMML(): String = {
val writer = new StringWriter
toPMML(new StreamResult(writer))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment