@KFStep(name="Classifier", category="Classifiers", toolTipText="Weka classifier wrapper", iconPath="", resourceIntensive=true) public class Classifier extends WekaAlgorithmWrapper implements PairedDataHelper.PairedProcessor<Classifier>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_classifierIsIncremental
True if the classifier in use is Updateable
|
protected Classifier |
m_classifierTemplate
The template for constructing concrete instances of the classifier to train
|
protected Data |
m_incrementalData
Reusable data for incremental streaming classifiers
|
protected boolean |
m_isReset
True if we've been reset
|
protected java.io.File |
m_loadModelFileName
Optional file to load a pre-trained model to score with (batch, or to score
and update (incremental) in the case of testSet only (batch) or instance
(incremental) connections
|
protected boolean |
m_resetIncrementalClassifier
True if we should resent an Updateable classifier at the start of
processing for an incoming "instance" stream
|
protected boolean |
m_streaming
True if we are processing streaming data
|
protected Classifier |
m_trainedClassifier
Holds the trained classifier in the case of single train/test pairs or
instance stream connections
|
protected Instances |
m_trainedClassifierHeader |
protected PairedDataHelper<Classifier> |
m_trainTestHelper
Handles train test pair routing and synchronization for us
|
protected boolean |
m_updateIncrementalClassifier
True if we should update an incremental classifier when there is a incoming
"instance" stream
|
m_defaultIconPath, m_defaultPackageIconPath, m_iconPath, m_wrappedAlgorithmm_stepIsResourceIntensive, m_stepManager, m_stepName| Constructor and Description |
|---|
Classifier() |
| Modifier and Type | Method and Description |
|---|---|
Classifier |
getClassifier()
Get the classifier to train
|
java.util.List<java.lang.String> |
getIncomingConnectionTypes()
Get a list of incoming connection types that this step can accept.
|
java.io.File |
getLoadClassifierFileName()
Get the name of the classifier to load at execution time.
|
java.util.List<java.lang.String> |
getOutgoingConnectionTypes()
Get a list of outgoing connection types that this step can produce.
|
boolean |
getResetIncrementalClassifier()
Get whether to reset an incremental classifier at the start of an incoming
instance stream
|
boolean |
getUpdateIncrementalClassifier()
Get whether to update an incremental classifier on an incoming instance
stream
|
java.lang.Class |
getWrappedAlgorithmClass()
Get the class of the algorithm being wrapped
|
protected void |
loadModel(java.lang.String filePath)
Load a pre-trained model from the supplied path
|
protected void |
outputGraphData(Classifier classifier,
int setNum)
Output a Data object containing a dot graph, if the model is Drawable and
we have downstream steps receiving graph connections.
|
protected void |
outputTextData(Classifier classifier,
int setNum)
Output a Data object containing a textual description of a model to any
outgoing text connections
|
void |
processIncoming(Data data)
Process an incoming data payload (if the step accepts incoming connections)
|
protected void |
processOnlyTestSet(Data data)
Process a Data object in the case where we only have an incoming testSet
connection
|
Classifier |
processPrimary(java.lang.Integer setNum,
java.lang.Integer maxSetNum,
Data data,
PairedDataHelper<Classifier> helper)
Process a training split (primary data handled by the PairedDataHelper)
|
void |
processSecondary(java.lang.Integer setNum,
java.lang.Integer maxSetNum,
Data data,
PairedDataHelper<Classifier> helper)
Process a test split/fold (secondary data handled by PairedDataHelper)
|
protected void |
processStreaming(Data data)
Process a Data object in the case of an incoming instance (streaming)
connection
|
void |
setClassifier(Classifier classifier)
Set the classifier to train
|
void |
setLoadClassifierFileName(java.io.File filename)
Set the name of the classifier to load at execution time.
|
void |
setResetIncrementalClassifier(boolean reset)
Set whether to reset an incremental classifier at the start of an incoming
instance stream
|
void |
setUpdateIncrementalClassifier(boolean update)
Set whether to update an incremental classifier on an incoming instance
stream
|
void |
setWrappedAlgorithm(java.lang.Object algo)
Set the wrapped algorithm
|
void |
stepInit()
Initialize the step.
|
getDefaultIconPath, getDefaultPackageLevelIconPath, getIconPath, getWrappedAlgorithm, globalInfoenvironmentSubstitute, getCustomEditorForStep, getDefaultSettings, getInteractiveViewers, getInteractiveViewersImpls, getName, getStepManager, isResourceIntensive, isStopRequested, outputStructureForConnectionType, setName, setStepIsResourceIntensive, setStepManager, setStepMustRunSingleThreaded, start, stepMustRunSingleThreaded, stopprotected Classifier m_classifierTemplate
protected Classifier m_trainedClassifier
protected Instances m_trainedClassifierHeader
protected java.io.File m_loadModelFileName
protected boolean m_resetIncrementalClassifier
protected boolean m_updateIncrementalClassifier
protected boolean m_streaming
protected boolean m_classifierIsIncremental
protected transient PairedDataHelper<Classifier> m_trainTestHelper
protected Data m_incrementalData
protected boolean m_isReset
public java.lang.Class getWrappedAlgorithmClass()
WekaAlgorithmWrappergetWrappedAlgorithmClass in class WekaAlgorithmWrapperpublic void setWrappedAlgorithm(java.lang.Object algo)
WekaAlgorithmWrappersetWrappedAlgorithm in class WekaAlgorithmWrapperalgo - the algorithm to wraopublic Classifier getClassifier()
@ProgrammaticProperty public void setClassifier(Classifier classifier)
classifier - the classifier to trainpublic void stepInit()
throws WekaException
StepstepInit in interface BaseStepExtenderstepInit in interface StepWekaException - if a problem occurs during initializationpublic java.io.File getLoadClassifierFileName()
@OptionMetadata(displayName="Classifier model to load", description="Optional Path to a classifier to load at execution time (only applies when using testSet or instance connections)") @FilePropertyMetadata(fileChooserDialogType=0, directoriesOnly=false) public void setLoadClassifierFileName(java.io.File filename)
filename - the name of the file to load the model frompublic boolean getResetIncrementalClassifier()
@OptionMetadata(displayName="Reset incremental classifier", description="Reset classifier (if it is incremental) at the start of the incoming instance stream") public void setResetIncrementalClassifier(boolean reset)
reset - true if the classifier should be resetpublic boolean getUpdateIncrementalClassifier()
@OptionMetadata(displayName="Update incremental classifier", description=" Update an incremental classifier on incoming instance stream") public void setUpdateIncrementalClassifier(boolean update)
update - true if an incremental classifier should be updatedpublic void processIncoming(Data data) throws WekaException
BaseStepprocessIncoming in interface BaseStepExtenderprocessIncoming in interface StepprocessIncoming in class BaseStepdata - the payload to processWekaException - if a problem occurspublic Classifier processPrimary(java.lang.Integer setNum, java.lang.Integer maxSetNum, Data data, PairedDataHelper<Classifier> helper) throws WekaException
processPrimary in interface PairedDataHelper.PairedProcessor<Classifier>setNum - the number of this split/foldmaxSetNum - the maximum number of splits/folds in the groupdata - the actual split/fold datahelper - the PairedDataHelper managing the paired dataWekaException - if a problem occurspublic void processSecondary(java.lang.Integer setNum,
java.lang.Integer maxSetNum,
Data data,
PairedDataHelper<Classifier> helper)
throws WekaException
processSecondary in interface PairedDataHelper.PairedProcessor<Classifier>setNum - the set number of this split/foldmaxSetNum - the maximum number of splits/folds in the groupdata - the actual split/fold datahelper - the PairedDataHelper managing the paried dataWekaException - if a problem occursprotected void processOnlyTestSet(Data data) throws WekaException
data - the Data object to processWekaException - if a problem occursprotected void processStreaming(Data data) throws WekaException
data - the Data object to processWekaException - if a problem occursprotected void outputTextData(Classifier classifier, int setNum) throws WekaException
classifier - the classifier to get the textual description ofsetNum - the set number of the training dataWekaException - if a problem occursprotected void outputGraphData(Classifier classifier, int setNum) throws WekaException
classifier - the classifier to generate the graph fromsetNum - the set number of the data used to generate the graphWekaException - if a problem occurspublic java.util.List<java.lang.String> getIncomingConnectionTypes()
StepgetIncomingConnectionTypes in interface BaseStepExtendergetIncomingConnectionTypes in interface Steppublic java.util.List<java.lang.String> getOutgoingConnectionTypes()
StepgetOutgoingConnectionTypes in interface BaseStepExtendergetOutgoingConnectionTypes in interface Stepprotected void loadModel(java.lang.String filePath)
throws java.lang.Exception
filePath - the path to load the model fromjava.lang.Exception - if a problem occurs