Package org.pentaho.di.scoring
Class WekaScoringModel
java.lang.Object
org.pentaho.di.scoring.WekaScoringModel
- All Implemented Interfaces:
Serializable
Abstract wrapper class for a Weka model. Provides a unified interface to
obtaining predictions. Subclasses ( WekaScoringClassifer and
WekaScoringClusterer) encapsulate the actual weka models.
- Version:
- 1.0
- Author:
- Mark Hall (mhall{[at]}pentaho.org)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract double
classifyInstance
(weka.core.Instance inst) Return a classification.abstract double[]
classifyInstances
(weka.core.Instances insts) Batch scoring method.static WekaScoringModel
createScorer
(Object model) Static factory method to create an instance of an appropriate subclass of WekaScoringModel given a Weka model.abstract double[]
distributionForInstance
(weka.core.Instance inst) Return a probability distribution (over classes or clusters).abstract double[][]
distributionsForInstances
(weka.core.Instances insts) Batch scoring method.void
done()
Tell the model that this scoring run is finished.weka.core.Instances
Get the header of the Instances that was used build this Weka modelabstract Object
getModel()
Get the weka modelabstract boolean
Returns true if the encapsulated Weka model can produce predictions in a batch.abstract boolean
Returns true if the encapsulated Weka model is a supervised model (i.e.abstract boolean
Returns true if the encapsulated Weka model can be updated incrementally in an instance by instance fashion.void
setHeader
(weka.core.Instances header) Set the Instances headervoid
setLog
(org.pentaho.di.core.logging.LogChannelInterface log) Set the log to pass on to the model.abstract void
Set the weka modelabstract boolean
update
(weka.core.Instance inst) Update (if possible) a model with the supplied Instance
-
Constructor Details
-
WekaScoringModel
Creates a newWekaScoringModel
instance.- Parameters:
model
- the actual Weka model to enacpsulate
-
-
Method Details
-
setLog
public void setLog(org.pentaho.di.core.logging.LogChannelInterface log) Set the log to pass on to the model. Only PMML models require logging.- Parameters:
log
- the log to use
-
setHeader
public void setHeader(weka.core.Instances header) Set the Instances header- Parameters:
header
- anInstances
value
-
getHeader
public weka.core.Instances getHeader()Get the header of the Instances that was used build this Weka model- Returns:
- an
Instances
value
-
done
public void done()Tell the model that this scoring run is finished. -
setModel
Set the weka model- Parameters:
model
- the Weka model
-
getModel
Get the weka model- Returns:
- the Weka model as an object
-
classifyInstance
Return a classification. What this represents depends on the implementing sub-class. It could be the index of a class-value, a numeric value or a cluster number for example.- Parameters:
inst
- the Instance to be classified (predicted)- Returns:
- the prediction
- Throws:
Exception
- if an error occurs
-
distributionForInstance
Return a probability distribution (over classes or clusters).- Parameters:
inst
- the Instance to be predicted- Returns:
- a probability distribution
- Throws:
Exception
- if an error occurs
-
classifyInstances
Batch scoring method. Call isBatchPredictor() first in order to determine if the underlying model can handle batch scoring.- Parameters:
insts
- the instances to score- Returns:
- an array of predictions
- Throws:
Exception
- if a problem occurs
-
distributionsForInstances
Batch scoring method. Call isBatchPredictor() first in order to determine if the underlying model can handle batch scoring.- Parameters:
insts
- the instances to score- Returns:
- an array of probability distributions, one for each instance
- Throws:
Exception
- if a problem occurs
-
isSupervisedLearningModel
public abstract boolean isSupervisedLearningModel()Returns true if the encapsulated Weka model is a supervised model (i.e. has been built to predict a single target in the data).- Returns:
- true if the encapsulated Weka model is a supervised model
-
isUpdateableModel
public abstract boolean isUpdateableModel()Returns true if the encapsulated Weka model can be updated incrementally in an instance by instance fashion.- Returns:
- true if the encapsulated Weka model is incremental model
-
isBatchPredictor
public abstract boolean isBatchPredictor()Returns true if the encapsulated Weka model can produce predictions in a batch.- Returns:
- true if the encapsulated Weka model can produce predictions in a batch
-
update
Update (if possible) a model with the supplied Instance- Parameters:
inst
- the Instance to update the model with- Returns:
- true if the model was updated
- Throws:
Exception
- if an error occurs
-
createScorer
Static factory method to create an instance of an appropriate subclass of WekaScoringModel given a Weka model.- Parameters:
model
- a Weka model- Returns:
- an appropriate WekaScoringModel for this type of Weka model
- Throws:
Exception
- if an error occurs
-