org.jpmml.model.JAXBUtil Scala Examples
The following examples show how to use org.jpmml.model.JAXBUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: PmmlLoaderKit.scala From flink-jpmml with GNU Affero General Public License v3.0 | 5 votes |
package io.radicalbit.flink.pmml.scala.utils import org.dmg.pmml.PMML import org.jpmml.model.{ImportFilter, JAXBUtil} import org.xml.sax.InputSource trait PmmlLoaderKit { protected case object Source { val KmeansPmml = "/kmeans.xml" val KmeansPmml41 = "/kmeans41.xml" val KmeansPmml40 = "/kmeans40.xml" val KmeansPmml42 = "/kmeans42.xml" val KmeansPmml32 = "/kmeans41.xml" val KmeansPmmlEmpty = "/kmeans_empty.xml" val KmeansPmmlNoOut = "/kmeans_nooutput.xml" val KmeansPmmlStringFields = "/kmeans_stringfields.xml" val KmeansPmmlNoOutNoTrg = "/kmeans_nooutput_notarget.xml" val NotExistingPath: String = "/not/existing/" + scala.util.Random.nextString(4) } final protected def getPMMLSource(path: String): String = getClass.getResource(path).getPath final protected def getPMMLResource(path: String): PMML = { val source = scala.io.Source.fromURL(getClass.getResource(path)).reader() JAXBUtil.unmarshalPMML(ImportFilter.apply(new InputSource(source))) } }
Example 2
Source File: ExportModel.scala From cdsw-simple-serving with Apache License 2.0 | 5 votes |
package com.cloudera.datascience.cdsw.acme import java.nio.charset.StandardCharsets import java.nio.file.StandardOpenOption._ import java.nio.file.{Files, Paths} import javax.xml.transform.stream.StreamResult import org.dmg.pmml.Application import org.jpmml.model.JAXBUtil import org.jpmml.sparkml.ConverterUtil import acme.ACMEModel object ExportModel { def main(args: Array[String]): Unit = { val training = ACMEData.readData() val pipeline = ACMEModel.buildModel() val pmml = ConverterUtil.toPMML(training.schema, pipeline) pmml.getHeader.setApplication(new Application("ACME Occupancy Detection")) val modelPath = Paths.get("src", "main", "resources") if (!Files.exists(modelPath)) { Files.createDirectory(modelPath) } val pmmlFile = modelPath.resolve("model.pmml") val writer = Files.newBufferedWriter(pmmlFile, StandardCharsets.UTF_8, WRITE, CREATE, TRUNCATE_EXISTING) try { JAXBUtil.marshalPMML(pmml, new StreamResult(writer)) } finally { writer.close() } } }
Example 3
Source File: PMMLUtils.scala From sona with Apache License 2.0 | 5 votes |
package com.tencent.angel.sona.ml.util import java.io.StringReader import org.dmg.pmml._ import org.jpmml.model.{ImportFilter, JAXBUtil} import org.xml.sax.InputSource /** * Testing utils for working with PMML. * Predictive Model Markup Language (PMML) is an XML-based file format * developed by the Data Mining Group (www.dmg.org). */ object PMMLUtils { /** * :: Experimental :: * Load a PMML model from a string. Note: for testing only, PMML model evaluation is supported * through external spark-packages. */ def loadFromString(input: String): PMML = { val is = new StringReader(input) val transformed = ImportFilter.apply(new InputSource(is)) JAXBUtil.unmarshalPMML(transformed) } }