Package weka.knowledgeflow.steps
Class Classifier
java.lang.Object
weka.knowledgeflow.steps.BaseStep
weka.knowledgeflow.steps.WekaAlgorithmWrapper
weka.knowledgeflow.steps.Classifier
- All Implemented Interfaces:
Serializable
,BaseStepExtender
,PairedDataHelper.PairedProcessor<Classifier>
,Step
@KFStep(name="Classifier",
category="Classifiers",
toolTipText="Weka classifier wrapper",
iconPath="",
resourceIntensive=true)
public class Classifier
extends WekaAlgorithmWrapper
implements PairedDataHelper.PairedProcessor<Classifier>
Step that wraps a Weka classifier. Handles instance, trainingSet and testSet
incoming connections. If the base classifier is Updateable, then it can be
optionally updated incrementall on an incoming connection of type instance.
Otherwise, instance connections are used for testing a classifier
incrementally. In the case of a single incoming testSet connection it is
assumed that the classifier has already been trained.
- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the classifier to trainGet a list of incoming connection types that this step can accept.Get the name of the classifier to load at execution time.Get a list of outgoing connection types that this step can produce.boolean
Get whether to reset an incremental classifier at the start of an incoming instance streamboolean
Get whether to update an incremental classifier on an incoming instance streamGet the class of the algorithm being wrappedvoid
processIncoming
(Data data) Process an incoming data payload (if the step accepts incoming connections)processPrimary
(Integer setNum, Integer maxSetNum, Data data, PairedDataHelper<Classifier> helper) Process a training split (primary data handled by the PairedDataHelper)void
processSecondary
(Integer setNum, Integer maxSetNum, Data data, PairedDataHelper<Classifier> helper) Process a test split/fold (secondary data handled by PairedDataHelper)void
setClassifier
(Classifier classifier) Set the classifier to trainvoid
setLoadClassifierFileName
(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 streamvoid
setUpdateIncrementalClassifier
(boolean update) Set whether to update an incremental classifier on an incoming instance streamvoid
setWrappedAlgorithm
(Object algo) Set the wrapped algorithmvoid
stepInit()
Initialize the step.Methods inherited from class weka.knowledgeflow.steps.WekaAlgorithmWrapper
getDefaultIconPath, getDefaultPackageLevelIconPath, getIconPath, getWrappedAlgorithm, globalInfo
Methods inherited from class weka.knowledgeflow.steps.BaseStep
environmentSubstitute, getCustomEditorForStep, getDefaultSettings, getInteractiveViewers, getInteractiveViewersImpls, getName, getStepManager, isResourceIntensive, isStopRequested, outputStructureForConnectionType, outputStructureForConnectionType, setName, setStepIsResourceIntensive, setStepManager, setStepMustRunSingleThreaded, start, stepMustRunSingleThreaded, stop
-
Constructor Details
-
Classifier
public Classifier()
-
-
Method Details
-
getWrappedAlgorithmClass
Description copied from class:WekaAlgorithmWrapper
Get the class of the algorithm being wrapped- Specified by:
getWrappedAlgorithmClass
in classWekaAlgorithmWrapper
- Returns:
- the class of the algorithm being wrapped
-
setWrappedAlgorithm
Description copied from class:WekaAlgorithmWrapper
Set the wrapped algorithm- Overrides:
setWrappedAlgorithm
in classWekaAlgorithmWrapper
- Parameters:
algo
- the algorithm to wrao
-
getClassifier
Get the classifier to train- Returns:
- the classifier to train
-
setClassifier
Set the classifier to train- Parameters:
classifier
- the classifier to train
-
stepInit
Description copied from interface:Step
Initialize the step.- Specified by:
stepInit
in interfaceBaseStepExtender
- Specified by:
stepInit
in interfaceStep
- Throws:
WekaException
- if a problem occurs during initialization
-
getLoadClassifierFileName
Get the name of the classifier to load at execution time. This only applies in the case where the only incoming connection is a test set connection (batch mode) or an instance connection (incremental mode).- Returns:
- the name of the file to load the model from
-
setLoadClassifierFileName
@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(File filename) Set the name of the classifier to load at execution time. This only applies in the case where the only incoming connection is a test set connection (batch mode) or an instance connection (incremental mode).- Parameters:
filename
- the name of the file to load the model from
-
getResetIncrementalClassifier
public boolean getResetIncrementalClassifier()Get whether to reset an incremental classifier at the start of an incoming instance stream- Returns:
- true if the classifier should be reset
-
setResetIncrementalClassifier
@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) Set whether to reset an incremental classifier at the start of an incoming instance stream- Parameters:
reset
- true if the classifier should be reset
-
getUpdateIncrementalClassifier
public boolean getUpdateIncrementalClassifier()Get whether to update an incremental classifier on an incoming instance stream- Returns:
- true if an incremental classifier should be updated
-
setUpdateIncrementalClassifier
@OptionMetadata(displayName="Update incremental classifier", description=" Update an incremental classifier on incoming instance stream") public void setUpdateIncrementalClassifier(boolean update) Set whether to update an incremental classifier on an incoming instance stream- Parameters:
update
- true if an incremental classifier should be updated
-
processIncoming
Description copied from class:BaseStep
Process an incoming data payload (if the step accepts incoming connections)- Specified by:
processIncoming
in interfaceBaseStepExtender
- Specified by:
processIncoming
in interfaceStep
- Overrides:
processIncoming
in classBaseStep
- Parameters:
data
- the payload to process- Throws:
WekaException
- if a problem occurs
-
processPrimary
public Classifier processPrimary(Integer setNum, Integer maxSetNum, Data data, PairedDataHelper<Classifier> helper) throws WekaException Process a training split (primary data handled by the PairedDataHelper)- Specified by:
processPrimary
in interfacePairedDataHelper.PairedProcessor<Classifier>
- Parameters:
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 data- Returns:
- a Classifier trained on this training split
- Throws:
WekaException
- if a problem occurs
-
processSecondary
public void processSecondary(Integer setNum, Integer maxSetNum, Data data, PairedDataHelper<Classifier> helper) throws WekaException Process a test split/fold (secondary data handled by PairedDataHelper)- Specified by:
processSecondary
in interfacePairedDataHelper.PairedProcessor<Classifier>
- Parameters:
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 data- Throws:
WekaException
- if a problem occurs
-
getIncomingConnectionTypes
Description copied from interface:Step
Get a list of incoming connection types that this step can accept. Ideally (and if appropriate), this should take into account the state of the step and any existing incoming connections. E.g. a step might be able to accept one (and only one) incoming batch data connection.- Specified by:
getIncomingConnectionTypes
in interfaceBaseStepExtender
- Specified by:
getIncomingConnectionTypes
in interfaceStep
- Returns:
- a list of incoming connections that this step can accept given its current state
-
getOutgoingConnectionTypes
Description copied from interface:Step
Get a list of outgoing connection types that this step can produce. Ideally (and if appropriate), this should take into account the state of the step and the incoming connections. E.g. depending on what incoming connection is present, a step might be able to produce a trainingSet output, a testSet output or neither, but not both.- Specified by:
getOutgoingConnectionTypes
in interfaceBaseStepExtender
- Specified by:
getOutgoingConnectionTypes
in interfaceStep
- Returns:
- a list of outgoing connections that this step can produce
-