|
17 | 17 |
|
18 | 18 | package org.apache.spark.mllib.export.pmml |
19 | 19 |
|
20 | | -import org.apache.spark.mllib.export.ModelExport |
21 | | -import java.io.OutputStream |
22 | | -import org.jpmml.model.JAXBUtil |
23 | | -import org.dmg.pmml.PMML |
24 | | -import javax.xml.transform.stream.StreamResult |
| 20 | +import java.text.SimpleDateFormat |
| 21 | +import java.util.Date |
| 22 | + |
25 | 23 | import scala.beans.BeanProperty |
| 24 | + |
26 | 25 | import org.dmg.pmml.Application |
27 | | -import org.dmg.pmml.Timestamp |
28 | 26 | import org.dmg.pmml.Header |
29 | | -import java.text.SimpleDateFormat |
30 | | -import java.util.Date |
| 27 | +import org.dmg.pmml.PMML |
| 28 | +import org.dmg.pmml.Timestamp |
| 29 | + |
| 30 | +import org.apache.spark.mllib.export.ModelExport |
31 | 31 |
|
32 | | -trait PMMLModelExport extends ModelExport{ |
| 32 | +private[mllib] trait PMMLModelExport extends ModelExport{ |
33 | 33 |
|
34 | 34 | /** |
35 | 35 | * Holder of the exported model in PMML format |
36 | 36 | */ |
37 | 37 | @BeanProperty |
38 | | - var pmml: PMML = new PMML(); |
| 38 | + val pmml: PMML = new PMML(); |
39 | 39 |
|
40 | 40 | setHeader(pmml); |
41 | 41 |
|
42 | 42 | private def setHeader(pmml : PMML): Unit = { |
43 | | - var version = getClass().getPackage().getImplementationVersion() |
44 | | - var app = new Application().withName("Apache Spark MLlib").withVersion(version) |
45 | | - var timestamp = new Timestamp() |
| 43 | + val version = getClass().getPackage().getImplementationVersion() |
| 44 | + val app = new Application().withName("Apache Spark MLlib").withVersion(version) |
| 45 | + val timestamp = new Timestamp() |
46 | 46 | .withContent(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())) |
47 | | - var header = new Header() |
48 | | - .withCopyright("www.dmg.org") |
| 47 | + val header = new Header() |
| 48 | + .withCopyright("Apache Spark MLlib") |
49 | 49 | .withApplication(app) |
50 | 50 | .withTimestamp(timestamp); |
51 | 51 | pmml.setHeader(header); |
| 52 | + pmml.setVersion("4.2") |
52 | 53 | } |
53 | 54 |
|
54 | | - /** |
55 | | - * Write the exported model (in PMML XML) to the output stream specified |
56 | | - */ |
57 | | - @Override |
58 | | - def save(outputStream: OutputStream): Unit = { |
59 | | - JAXBUtil.marshalPMML(pmml, new StreamResult(outputStream)); |
60 | | - } |
61 | | - |
62 | 55 | } |
0 commit comments