public class PMMLFactory extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
PMMLFactory.ModelType
for serialization
|
Constructor and Description |
---|
PMMLFactory() |
Modifier and Type | Method and Description |
---|---|
static String |
applyClassifier(PMMLModel model,
Instances test) |
protected static Instances |
getDataDictionaryAsInstances(Document doc)
Get the data dictionary as an Instances object
|
protected static Instances |
getMiningSchemaAsInstances(Element model,
Instances dataDictionary)
Deprecated.
Use the MiningSchema class instead
|
protected static Element |
getModelElement(Document doc,
PMMLFactory.ModelType modelType)
Get the Element that contains the pmml model
|
protected static PMMLModel |
getModelInstance(Document doc,
PMMLFactory.ModelType modelType,
Element model,
Instances dataDictionary,
MiningSchema miningSchema)
Get an instance of a PMMLModel from the supplied Document
|
protected static PMMLFactory.ModelType |
getModelType(Document doc)
Get the type of model
|
static PMMLModel |
getPMMLModel(File file)
Read and return a PMML model.
|
static PMMLModel |
getPMMLModel(File file,
Logger log)
Read and return a PMML model.
|
static PMMLModel |
getPMMLModel(InputStream stream)
Read and return a PMML model.
|
static PMMLModel |
getPMMLModel(InputStream stream,
Logger log)
Read and return a PMML model.
|
static PMMLModel |
getPMMLModel(String filename)
Read and return a PMML model.
|
static PMMLModel |
getPMMLModel(String filename,
Logger log)
Read and return a PMML model.
|
protected static weka.core.pmml.TransformationDictionary |
getTransformationDictionary(Document doc,
Instances dataDictionary)
Get the transformation dictionary (if there is one).
|
static void |
main(String[] args) |
static void |
serializePMMLModel(PMMLModel model,
File file)
Serialize a
PMMLModel object that encapsulates a PMML model |
static void |
serializePMMLModel(PMMLModel model,
OutputStream stream)
Serialize a
PMMLModel object that encapsulates a PMML model |
static void |
serializePMMLModel(PMMLModel model,
String filename)
Serialize a
PMMLModel object that encapsulates a PMML model |
public static PMMLModel getPMMLModel(String filename) throws Exception
filename
- the name of the file to read fromException
- if there is a problem while reading the filepublic static PMMLModel getPMMLModel(File file) throws Exception
file
- a File
to read fromException
- if there is a problem while reading the filepublic static PMMLModel getPMMLModel(InputStream stream) throws Exception
stream
- the InputStream
to read fromException
- if there is a problem while reading from the streampublic static PMMLModel getPMMLModel(String filename, Logger log) throws Exception
filename
- the name of the file to read fromlog
- the logging object to use (or null if none is to be used)Exception
- if there is a problem while reading the filepublic static PMMLModel getPMMLModel(File file, Logger log) throws Exception
file
- a File
to read fromlog
- the logging object to use (or null if none is to be used)Exception
- if there is a problem while reading the filepublic static PMMLModel getPMMLModel(InputStream stream, Logger log) throws Exception
stream
- the InputStream
to read fromlog
- the logging object to use (or null if none is to be used)Exception
- if there is a problem while reading from the streamprotected static weka.core.pmml.TransformationDictionary getTransformationDictionary(Document doc, Instances dataDictionary) throws Exception
doc
- the Document containing the PMML modeldataDictionary
- the data dictionary as an Instances objectException
- if there is a problem getting the transformation
dictionarypublic static void serializePMMLModel(PMMLModel model, String filename) throws Exception
PMMLModel
object that encapsulates a PMML modelmodel
- the PMMLModel
to serializefilename
- the name of the file to save toException
- if something goes wrong during serializationpublic static void serializePMMLModel(PMMLModel model, File file) throws Exception
PMMLModel
object that encapsulates a PMML modelmodel
- the PMMLModel
to serializefile
- the File
to save toException
- if something goes wrong during serializationpublic static void serializePMMLModel(PMMLModel model, OutputStream stream) throws Exception
PMMLModel
object that encapsulates a PMML modelmodel
- the PMMLModel
to serializestream
- the OutputStream
to serialize toException
- if something goes wrong during serializationprotected static PMMLModel getModelInstance(Document doc, PMMLFactory.ModelType modelType, Element model, Instances dataDictionary, MiningSchema miningSchema) throws Exception
doc
- the Document holding the pmmlmodelType
- the type of modelmodel
- the Element encapsulating the model part of the DocumentdataDictionary
- the data dictionary as an Instances objectminingSchema
- the mining schemaException
- if there is a problem constructing the model or
if the model type is not supportedprotected static PMMLFactory.ModelType getModelType(Document doc)
doc
- the Document encapsulating the pmmlprotected static Element getModelElement(Document doc, PMMLFactory.ModelType modelType) throws Exception
doc
- the Document encapsulating the pmmlmodelType
- the type of modelException
- if the model type is unsupported/unknownprotected static Instances getMiningSchemaAsInstances(Element model, Instances dataDictionary) throws Exception
model
- the Element containing the pmml modeldataDictionary
- the data dictionary as an Instances objectException
- if something goes wrong during reading the mining schemaprotected static Instances getDataDictionaryAsInstances(Document doc) throws Exception
doc
- the Document encapsulating the pmmlException
- if there are fields that are not continuous,
ordinal or categorical in the data dictionarypublic static String applyClassifier(PMMLModel model, Instances test) throws Exception
Exception
public static void main(String[] args)
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.