public abstract class AbstractClassifier extends java.lang.Object implements Classifier, BatchPredictor, java.lang.Cloneable, java.io.Serializable, OptionHandler, CapabilitiesHandler, RevisionHandler, CapabilitiesIgnorer, CommandlineRunnable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BATCH_SIZE_DEFAULT
Default preferred batch size for batch predictions
|
static int |
NUM_DECIMAL_PLACES_DEFAULT
The number of decimal places used when printing numbers in the model.
|
Constructor and Description |
---|
AbstractClassifier() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
batchSizeTipText()
Returns the tip text for this property
|
double |
classifyInstance(Instance instance)
Classifies the given test instance.
|
java.lang.String |
debugTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Predicts the class memberships for a given instance.
|
double[][] |
distributionsForInstances(Instances batch)
Batch prediction method.
|
java.lang.String |
doNotCheckCapabilitiesTipText()
Returns the tip text for this property
|
static Classifier |
forName(java.lang.String classifierName,
java.lang.String[] options)
Creates a new instance of a classifier given it's class name and (optional)
arguments to pass to it's setOptions method.
|
java.lang.String |
getBatchSize()
Get the preferred batch size for batch prediction.
|
Capabilities |
getCapabilities()
Returns the Capabilities of this classifier.
|
boolean |
getDebug()
Get whether debugging is turned on.
|
boolean |
getDoNotCheckCapabilities()
Get whether capabilities checking is turned off.
|
int |
getNumDecimalPlaces()
Get the number of decimal places.
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
implementsMoreEfficientBatchPrediction()
Return true if this classifier can generate batch predictions in an
efficient manner.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static Classifier[] |
makeCopies(Classifier model,
int num)
Creates a given number of deep copies of the given classifier using
serialization.
|
static Classifier |
makeCopy(Classifier model)
Creates a deep copy of the given classifier using serialization.
|
java.lang.String |
numDecimalPlacesTipText()
Returns the tip text for this property
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before commandline
execution.
|
void |
run(java.lang.Object toRun,
java.lang.String[] options)
Execute the supplied object.
|
static void |
runClassifier(Classifier classifier,
java.lang.String[] options)
runs the classifier instance with the given options.
|
void |
setBatchSize(java.lang.String size)
Set the preferred batch size for batch prediction.
|
void |
setDebug(boolean debug)
Set debugging mode.
|
void |
setDoNotCheckCapabilities(boolean doNotCheckCapabilities)
Set whether not to check capabilities.
|
void |
setNumDecimalPlaces(int num)
Set the number of decimal places.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildClassifier
makeCopy
public static int NUM_DECIMAL_PLACES_DEFAULT
public static java.lang.String BATCH_SIZE_DEFAULT
public static Classifier forName(java.lang.String classifierName, java.lang.String[] options) throws java.lang.Exception
classifierName
- the fully qualified class name of the classifieroptions
- an array of options suitable for passing to setOptions. May
be null.java.lang.Exception
- if the classifier name is invalid, or the options
supplied are not acceptable to the classifierpublic static Classifier makeCopy(Classifier model) throws java.lang.Exception
model
- the classifier to copyjava.lang.Exception
- if an error occurspublic static Classifier[] makeCopies(Classifier model, int num) throws java.lang.Exception
model
- the classifier to copynum
- the number of classifier copies to create.java.lang.Exception
- if an error occurspublic static void runClassifier(Classifier classifier, java.lang.String[] options)
classifier
- the classifier to runoptions
- the commandline optionspublic double classifyInstance(Instance instance) throws java.lang.Exception
classifyInstance
in interface Classifier
instance
- the instance to be classifiedjava.lang.Exception
- if an error occurred during the predictionpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
instance
- the instance to be classifiedjava.lang.Exception
- if distribution could not be computed successfullypublic java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-output-debug-info
If set, classifier is run in debug mode and may output additional info to
the console.
-do-not-check-capabilities
If set, classifier capabilities are not checked before classifier is built
(use with caution).
-num-decimal-places
The number of decimal places for the output of numbers in the model.
-batch-size
The desired batch size for batch prediction.
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic boolean getDebug()
public void setDebug(boolean debug)
debug
- true if debug output should be printedpublic java.lang.String debugTipText()
public boolean getDoNotCheckCapabilities()
getDoNotCheckCapabilities
in interface CapabilitiesIgnorer
public void setDoNotCheckCapabilities(boolean doNotCheckCapabilities)
setDoNotCheckCapabilities
in interface CapabilitiesIgnorer
doNotCheckCapabilities
- true if capabilities are not to be checked.public java.lang.String doNotCheckCapabilitiesTipText()
public java.lang.String numDecimalPlacesTipText()
public int getNumDecimalPlaces()
public void setNumDecimalPlaces(int num)
public java.lang.String batchSizeTipText()
public void setBatchSize(java.lang.String size)
setBatchSize
in interface BatchPredictor
size
- the batch size to usepublic java.lang.String getBatchSize()
getBatchSize
in interface BatchPredictor
public boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction
in interface BatchPredictor
public double[][] distributionsForInstances(Instances batch) throws java.lang.Exception
distributionsForInstances
in interface BatchPredictor
batch
- the instances to get predictions forjava.lang.Exception
- if a problem occurs.public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
Capabilities
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
public void preExecution() throws java.lang.Exception
preExecution
in interface CommandlineRunnable
java.lang.Exception
- if a problem occurs during setuppublic void run(java.lang.Object toRun, java.lang.String[] options) throws java.lang.Exception
run
in interface CommandlineRunnable
toRun
- the object to executeoptions
- any options to pass to the objectjava.lang.Exception
- if the object is not of the expected type.public void postExecution() throws java.lang.Exception
postExecution
in interface CommandlineRunnable
java.lang.Exception
- if a problem occurs during teardown