public class CheckClassifier extends CheckScheme
java weka.classifiers.CheckClassifier -W classifier_name
classifier_options
CheckClassifier reports on the following:
weka.classifiers.AbstractClassifierTest
uses this
class to test all the classifiers. Any changes here, have to be
checked in that abstract test class, too.
Valid options are:
-D Turn on debugging output.
-S Silent mode - prints nothing to stdout.
-N <num> The number of instances in the datasets (default 20).
-nominal <num> The number of nominal attributes (default 2).
-nominal-values <num> The number of values for nominal attributes (default 1).
-numeric <num> The number of numeric attributes (default 1).
-string <num> The number of string attributes (default 1).
-date <num> The number of date attributes (default 1).
-relational <num> The number of relational attributes (default 1).
-num-instances-relational <num> The number of instances in relational/bag attributes (default 10).
-words <comma-separated-list> The words to use in string attributes.
-word-separators <chars> The word separators to use in string attributes.
-W Full name of the classifier analysed. eg: weka.classifiers.bayes.NaiveBayes (default weka.classifiers.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the consoleOptions after -- are passed to the designated classifier.
TestInstances
CheckScheme.PostProcessor
Modifier and Type | Field and Description |
---|---|
protected Classifier |
m_Classifier
The classifier to be examined
|
m_ClasspathProblems, m_NumDate, m_NumInstances, m_NumInstancesRelational, m_NumNominal, m_NumNumeric, m_NumRelational, m_NumString, m_PostProcessor, m_Words, m_WordSeparators
Constructor and Description |
---|
CheckClassifier() |
Modifier and Type | Method and Description |
---|---|
protected boolean[] |
canHandleClassAsNthAttribute(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType,
int classIndex)
Checks whether the scheme can handle class attributes as Nth attribute.
|
protected boolean[] |
canHandleMissing(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType,
boolean predictorMissing,
boolean classMissing,
int missingLevel)
Checks basic missing value handling of the scheme.
|
protected boolean[] |
canHandleNClasses(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int numClasses)
Checks whether nominal schemes can handle more than two classes.
|
protected boolean[] |
canHandleOnlyClass(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
int classType)
Checks whether the scheme can handle data that contains only the class
attribute.
|
protected boolean[] |
canHandleZeroTraining(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks whether the scheme can handle zero training instances.
|
protected boolean[] |
canPredict(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks basic prediction of the scheme, for simple non-troublesome
datasets.
|
protected boolean[] |
canTakeOptions()
Checks whether the scheme can take command line options.
|
protected boolean[] |
correctBuildInitialisation(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks whether the scheme correctly initialises models when
buildClassifier is called.
|
protected boolean[] |
datasetIntegrity(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType,
boolean predictorMissing,
boolean classMissing)
Checks whether the scheme alters the training dataset during
training.
|
protected boolean[] |
declaresSerialVersionUID()
tests for a serialVersionUID.
|
protected boolean[] |
doesntUseTestClassVal(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks whether the classifier erroneously uses the class
value of test instances (if provided).
|
void |
doTests()
Begin the tests, reporting results to System.out
|
Classifier |
getClassifier()
Get the classifier used as the classifier
|
String[] |
getOptions()
Gets the current settings of the CheckClassifier.
|
String |
getRevision()
Returns the revision string.
|
protected boolean[] |
instanceWeights(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks whether the classifier can handle instance weights.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] args)
Test method for this class
|
protected Instances |
makeTestDataset(int seed,
int numInstances,
int numNominal,
int numNumeric,
int numString,
int numDate,
int numRelational,
int numClasses,
int classType,
boolean multiInstance)
Make a simple set of instances, which can later be modified
for use in specific tests.
|
protected Instances |
makeTestDataset(int seed,
int numInstances,
int numNominal,
int numNumeric,
int numString,
int numDate,
int numRelational,
int numClasses,
int classType,
int classIndex,
boolean multiInstance)
Make a simple set of instances with variable position of the class
attribute, which can later be modified for use in specific tests.
|
protected boolean[] |
multiInstanceHandler()
Checks whether the scheme handles multi-instance data.
|
protected void |
printAttributeSummary(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Print out a short summary string for the dataset characteristics
|
protected boolean[] |
runBasicTest(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType,
int missingLevel,
boolean predictorMissing,
boolean classMissing,
int numTrain,
int numTest,
int numClasses,
FastVector accepts)
Runs a text on the datasets with the given characteristics.
|
protected boolean[] |
runBasicTest(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType,
int classIndex,
int missingLevel,
boolean predictorMissing,
boolean classMissing,
int numTrain,
int numTest,
int numClasses,
FastVector accepts)
Runs a text on the datasets with the given characteristics.
|
void |
setClassifier(Classifier newClassifier)
Set the classifier for boosting.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
protected void |
testsPerClassType(int classType,
boolean updateable,
boolean weighted,
boolean multiInstance)
Run a battery of tests for a given class attribute type
|
protected boolean[] |
testToString()
Checks whether the scheme's toString() method works even though the
classifies hasn't been built yet.
|
protected boolean[] |
testWRTZeroR(Classifier classifier,
Evaluation evaluation,
Instances train,
Instances test)
Determine whether the scheme performs worse than ZeroR during testing
|
protected boolean[] |
updateableClassifier()
Checks whether the scheme can build models incrementally.
|
protected boolean[] |
updatingEquality(boolean nominalPredictor,
boolean numericPredictor,
boolean stringPredictor,
boolean datePredictor,
boolean relationalPredictor,
boolean multiInstance,
int classType)
Checks whether an updateable scheme produces the same model when
trained incrementally as when batch trained.
|
protected boolean[] |
weightedInstancesHandler()
Checks whether the scheme says it can handle instance weights.
|
addMissing, arrayToList, attributeTypeToString, compareDatasets, getNumDate, getNumInstances, getNumInstancesRelational, getNumNominal, getNumNumeric, getNumRelational, getNumString, getPostProcessor, getWords, getWordSeparators, hasClasspathProblems, listToArray, process, setNumDate, setNumInstances, setNumInstancesRelational, setNumNominal, setNumNumeric, setNumRelational, setNumString, setPostProcessor, setWords, setWordSeparators
protected Classifier m_Classifier
public Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class CheckScheme
public void setOptions(String[] options) throws Exception
-D Turn on debugging output.
-S Silent mode - prints nothing to stdout.
-N <num> The number of instances in the datasets (default 20).
-nominal <num> The number of nominal attributes (default 2).
-nominal-values <num> The number of values for nominal attributes (default 1).
-numeric <num> The number of numeric attributes (default 1).
-string <num> The number of string attributes (default 1).
-date <num> The number of date attributes (default 1).
-relational <num> The number of relational attributes (default 1).
-num-instances-relational <num> The number of instances in relational/bag attributes (default 10).
-words <comma-separated-list> The words to use in string attributes.
-word-separators <chars> The word separators to use in string attributes.
-W Full name of the classifier analysed. eg: weka.classifiers.bayes.NaiveBayes (default weka.classifiers.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the console
setOptions
in interface OptionHandler
setOptions
in class CheckScheme
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class CheckScheme
public void doTests()
doTests
in class CheckScheme
public void setClassifier(Classifier newClassifier)
newClassifier
- the Classifier to use.public Classifier getClassifier()
protected void testsPerClassType(int classType, boolean updateable, boolean weighted, boolean multiInstance)
classType
- true if the class attribute should be numericupdateable
- true if the classifier is updateableweighted
- true if the classifier says it handles weightsmultiInstance
- true if the classifier is a multi-instance classifierprotected boolean[] testToString()
protected boolean[] declaresSerialVersionUID()
protected boolean[] canTakeOptions()
protected boolean[] updateableClassifier()
protected boolean[] weightedInstancesHandler()
protected boolean[] multiInstanceHandler()
protected boolean[] canPredict(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NOMINAL, NUMERIC, etc.)protected boolean[] canHandleOnlyClass(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesclassType
- the class type (NOMINAL, NUMERIC, etc.)protected boolean[] canHandleNClasses(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int numClasses)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is needednumClasses
- the number of classes to testprotected boolean[] canHandleClassAsNthAttribute(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, int classIndex)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)classIndex
- the index of the class attribute (0-based, -1 means last attribute)TestInstances.CLASS_IS_LAST
protected boolean[] canHandleZeroTraining(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)protected boolean[] correctBuildInitialisation(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)protected boolean[] canHandleMissing(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, boolean predictorMissing, boolean classMissing, int missingLevel)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)predictorMissing
- true if the missing values may be in
the predictorsclassMissing
- true if the missing values may be in the classmissingLevel
- the percentage of missing valuesprotected boolean[] updatingEquality(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)protected boolean[] doesntUseTestClassVal(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)protected boolean[] instanceWeights(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)protected boolean[] datasetIntegrity(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, boolean predictorMissing, boolean classMissing)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)predictorMissing
- true if we know the classifier can handle
(at least) moderate missing predictor valuesclassMissing
- true if we know the classifier can handle
(at least) moderate missing class valuesprotected boolean[] runBasicTest(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, int missingLevel, boolean predictorMissing, boolean classMissing, int numTrain, int numTest, int numClasses, FastVector accepts)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)missingLevel
- the percentage of missing valuespredictorMissing
- true if the missing values may be in
the predictorsclassMissing
- true if the missing values may be in the classnumTrain
- the number of instances in the training setnumTest
- the number of instaces in the test setnumClasses
- the number of classesaccepts
- the acceptable string in an exceptionprotected boolean[] runBasicTest(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, int classIndex, int missingLevel, boolean predictorMissing, boolean classMissing, int numTrain, int numTest, int numClasses, FastVector accepts)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesstringPredictor
- if true use string predictor attributesdatePredictor
- if true use date predictor attributesrelationalPredictor
- if true use relational predictor attributesmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)classIndex
- the attribute index of the classmissingLevel
- the percentage of missing valuespredictorMissing
- true if the missing values may be in
the predictorsclassMissing
- true if the missing values may be in the classnumTrain
- the number of instances in the training setnumTest
- the number of instaces in the test setnumClasses
- the number of classesaccepts
- the acceptable string in an exceptionprotected boolean[] testWRTZeroR(Classifier classifier, Evaluation evaluation, Instances train, Instances test) throws Exception
classifier
- the pre-trained classifierevaluation
- the classifier evaluation objecttrain
- the training datatest
- the test dataException
- if there was a problem during the scheme's testingprotected Instances makeTestDataset(int seed, int numInstances, int numNominal, int numNumeric, int numString, int numDate, int numRelational, int numClasses, int classType, boolean multiInstance) throws Exception
seed
- the random number seednumInstances
- the number of instances to generatenumNominal
- the number of nominal attributesnumNumeric
- the number of numeric attributesnumString
- the number of string attributesnumDate
- the number of date attributesnumRelational
- the number of relational attributesnumClasses
- the number of classes (if nominal class)classType
- the class type (NUMERIC, NOMINAL, etc.)multiInstance
- whether the dataset should a multi-instance datasetException
- if the dataset couldn't be generatedCheckScheme.process(Instances)
protected Instances makeTestDataset(int seed, int numInstances, int numNominal, int numNumeric, int numString, int numDate, int numRelational, int numClasses, int classType, int classIndex, boolean multiInstance) throws Exception
seed
- the random number seednumInstances
- the number of instances to generatenumNominal
- the number of nominal attributesnumNumeric
- the number of numeric attributesnumString
- the number of string attributesnumDate
- the number of date attributesnumRelational
- the number of relational attributesnumClasses
- the number of classes (if nominal class)classType
- the class type (NUMERIC, NOMINAL, etc.)classIndex
- the index of the class (0-based, -1 as last)multiInstance
- whether the dataset should a multi-instance datasetException
- if the dataset couldn't be generatedTestInstances.CLASS_IS_LAST
,
CheckScheme.process(Instances)
protected void printAttributeSummary(boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType)
nominalPredictor
- true if nominal predictor attributes are presentnumericPredictor
- true if numeric predictor attributes are presentstringPredictor
- true if string predictor attributes are presentdatePredictor
- true if date predictor attributes are presentrelationalPredictor
- true if relational predictor attributes are presentmultiInstance
- whether multi-instance is neededclassType
- the class type (NUMERIC, NOMINAL, etc.)public String getRevision()
public static void main(String[] args)
args
- the commandline parametersCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.