|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.CheckClassifier
Class for examining the capabilities and finding problems with classifiers. If you implement a classifier using the WEKA.libraries, you should run the checks on it to ensure robustness and correct operation. Passing all the tests of this object does not mean bugs in the classifier don't exist, but this will help find some common ones.
Typical usage:
java weka.classifiers.CheckClassifier -W classifier_name
classifier_options
CheckClassifier reports on the following:
Valid options are:
-D
Turn on debugging output.
-W classname
Specify the full class name of a classifier to perform the
tests on (required).
Options after -- are passed to the designated classifier.
Field Summary | |
protected java.lang.String |
m_AnalysisResults
The results of the analysis as a string |
protected Classifier |
m_Classifier
The classifier to be examined |
protected java.lang.String[] |
m_ClassifierOptions
The options to be passed to the base classifier. |
protected boolean |
m_Debug
Debugging mode, gives extra output if true |
Constructor Summary | |
CheckClassifier()
|
Method Summary | |
protected void |
addMissing(Instances data,
int level,
boolean predictorMissing,
boolean classMissing)
Add missing values to a dataset. |
protected boolean |
canHandleMissing(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass,
boolean predictorMissing,
boolean classMissing,
int missingLevel)
Checks basic missing value handling of the scheme. |
protected boolean |
canHandleNClasses(boolean nominalPredictor,
boolean numericPredictor,
int numClasses)
Checks whether nominal schemes can handle more than two classes. |
protected boolean |
canHandleZeroTraining(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
Checks whether the scheme can handle zero training instances. |
protected boolean |
canPredict(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
Checks basic prediction of the scheme, for simple non-troublesome datasets. |
protected boolean |
canTakeOptions()
Checks whether the scheme can take command line options. |
protected void |
compareDatasets(Instances data1,
Instances data2)
Compare two datasets to see if they differ. |
protected boolean |
correctBuildInitialisation(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
Checks whether the scheme correctly initialises models when buildClassifier is called. |
protected boolean |
datasetIntegrity(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass,
boolean predictorMissing,
boolean classMissing)
Checks whether the scheme alters the training dataset during training. |
protected boolean |
doesntUseTestClassVal(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
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 |
boolean |
getDebug()
Get whether debugging is turned on |
java.lang.String[] |
getOptions()
Gets the current settings of the CheckClassifier. |
protected boolean |
instanceWeights(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
Checks whether the classifier can handle instance weights. |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] args)
Test method for this class |
protected Instances |
makeTestDataset(int seed,
int numInstances,
int numNominal,
int numNumeric,
int numClasses,
boolean numericClass)
Make a simple set of instances, which can later be modified for use in specific tests. |
protected void |
printAttributeSummary(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass)
Print out a short summary string for the dataset characteristics |
protected boolean |
runBasicTest(boolean nominalPredictor,
boolean numericPredictor,
boolean numericClass,
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 |
setDebug(boolean debug)
Set debugging mode |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
protected void |
testsPerClassType(boolean numericClass,
boolean updateable,
boolean weighted)
Run a battery of tests for a given class attribute type |
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 numericClass)
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Classifier m_Classifier
protected java.lang.String[] m_ClassifierOptions
protected java.lang.String m_AnalysisResults
protected boolean m_Debug
Constructor Detail |
public CheckClassifier()
Method Detail |
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-D
Turn on debugging output.
-W classname
Specify the full class name of a classifier to perform the
tests on (required).
Options after -- are passed to the designated classifier
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void doTests()
public void setDebug(boolean debug)
debug
- true if debug output should be printedpublic boolean getDebug()
public void setClassifier(Classifier newClassifier)
newClassifier
- the Classifier to use.public Classifier getClassifier()
public static void main(java.lang.String[] args)
protected void testsPerClassType(boolean numericClass, boolean updateable, boolean weighted)
numericClass
- true if the class attribute should be numericupdateable
- true if the classifier is updateableweighted
- true if the classifier says it handles weightsprotected boolean canTakeOptions()
protected boolean updateableClassifier()
protected boolean weightedInstancesHandler()
protected boolean canPredict(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean canHandleNClasses(boolean nominalPredictor, boolean numericPredictor, int numClasses)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumClasses
- the number of classes to test
protected boolean canHandleZeroTraining(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean correctBuildInitialisation(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean canHandleMissing(boolean nominalPredictor, boolean numericPredictor, boolean numericClass, boolean predictorMissing, boolean classMissing, int missingLevel)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attributepredictorMissing
- true if the missing values may be in
the predictorsclassMissing
- true if the missing values may be in the class
protected boolean updatingEquality(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean doesntUseTestClassVal(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean instanceWeights(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attribute
protected boolean datasetIntegrity(boolean nominalPredictor, boolean numericPredictor, boolean numericClass, boolean predictorMissing, boolean classMissing)
nominalPredictor
- if true use nominal predictor attributesnumericPredictor
- if true use numeric predictor attributesnumericClass
- if true use a numeric class attribute otherwise a
nominal class attributepredictorMissing
- 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 values
protected boolean runBasicTest(boolean nominalPredictor, boolean numericPredictor, boolean numericClass, int missingLevel, boolean predictorMissing, boolean classMissing, int numTrain, int numTest, int numClasses, FastVector accepts)
protected boolean testWRTZeroR(Classifier classifier, Evaluation evaluation, Instances train, Instances test) throws java.lang.Exception
classifier
- the pre-trained classifierevaluation
- the classifier evaluation objecttrain
- the training datatest
- the test data
java.lang.Exception
- if there was a problem during the scheme's testingprotected void compareDatasets(Instances data1, Instances data2) throws java.lang.Exception
data1
- one set of instancesdata2
- the other set of instances
java.lang.Exception
- if the datasets differprotected void addMissing(Instances data, int level, boolean predictorMissing, boolean classMissing)
data
- the instances to add missing values tolevel
- the level of missing values to add (if positive, this
is the probability that a value will be set to missing, if negative
all but one value will be set to missing (not yet implemented))predictorMissing
- if true, predictor attributes will be modifiedclassMissing
- if true, the class attribute will be modifiedprotected Instances makeTestDataset(int seed, int numInstances, int numNominal, int numNumeric, int numClasses, boolean numericClass) throws java.lang.Exception
seed
- the random number seednumInstances
- the number of instances to generatenumNominal
- the number of nominal attributesnumNumeric
- the number of numeric attributesnumClasses
- the number of classes (if nominal class)numericClass
- true if the class attribute should be numeric
java.lang.Exception
- if the dataset couldn't be generatedprotected void printAttributeSummary(boolean nominalPredictor, boolean numericPredictor, boolean numericClass)
nominalPredictor
- true if nominal predictor attributes are presentnumericPredictor
- true if numeric predictor attributes are presentnumericClass
- true if the class attribute is numeric
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |