Package weka.classifiers.rules
Class OneR
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.rules.OneR
- All Implemented Interfaces:
Serializable,Cloneable,Classifier,Sourcable,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,RevisionHandler,TechnicalInformationHandler
Class for building and using a 1R classifier; in
other words, uses the minimum-error attribute for prediction, discretizing
numeric attributes. For more information, see:
R.C. Holte (1993). Very simple classification rules perform well on most commonly used datasets. Machine Learning. 11:63-91. BibTeX:
R.C. Holte (1993). Very simple classification rules perform well on most commonly used datasets. Machine Learning. 11:63-91. BibTeX:
@article{Holte1993,
author = {R.C. Holte},
journal = {Machine Learning},
pages = {63-91},
title = {Very simple classification rules perform well on most commonly used datasets},
volume = {11},
year = {1993}
}
Valid options are:
-B <minimum bucket size> The minimum number of objects in a bucket (default: 6).
- Version:
- $Revision: 10153 $
- Author:
- Ian H. Witten (ihw@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances instances) Generates the classifier.doubleclassifyInstance(Instance inst) Classifies a given instance.Returns default capabilities of the classifier.intGet the value of minBucketSize.String[]Gets the current settings of the OneR classifier.Returns the revision string.Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.Returns a string describing classifierReturns an enumeration describing the available options..static voidMain method for testing this classReturns the tip text for this propertyweka.classifiers.rules.OneR.OneRRulenewNominalRule(Attribute attr, Instances data, int[] missingValueCounts) Create a rule branching on this nominal attribute.weka.classifiers.rules.OneR.OneRRulenewNumericRule(Attribute attr, Instances data, int[] missingValueCounts) Create a rule branching on this numeric attributeweka.classifiers.rules.OneR.OneRRuleCreate a rule branching on this attribute.voidsetMinBucketSize(int v) Set the value of minBucketSize.voidsetOptions(String[] options) Parses a given list of options.Returns a string that describes the classifier as source.toString()Returns a description of the classifierMethods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
Constructor Details
-
OneR
public OneR()
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
classifyInstance
Classifies a given instance.- Specified by:
classifyInstancein interfaceClassifier- Overrides:
classifyInstancein classAbstractClassifier- Parameters:
inst- the instance to be classified- Returns:
- the classification of the instance
- Throws:
Exception- if an error occurred during the prediction
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClassifier- Overrides:
getCapabilitiesin classAbstractClassifier- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Generates the classifier.- Specified by:
buildClassifierin interfaceClassifier- Parameters:
instances- the instances to be used for building the classifier- Throws:
Exception- if the classifier can't be built successfully
-
newRule
public weka.classifiers.rules.OneR.OneRRule newRule(Attribute attr, Instances data) throws Exception Create a rule branching on this attribute.- Parameters:
attr- the attribute to branch ondata- the data to be used for creating the rule- Returns:
- the generated rule
- Throws:
Exception- if the rule can't be built successfully
-
newNominalRule
public weka.classifiers.rules.OneR.OneRRule newNominalRule(Attribute attr, Instances data, int[] missingValueCounts) throws Exception Create a rule branching on this nominal attribute.- Parameters:
attr- the attribute to branch ondata- the data to be used for creating the rulemissingValueCounts- to be filled in- Returns:
- the generated rule
- Throws:
Exception- if the rule can't be built successfully
-
newNumericRule
public weka.classifiers.rules.OneR.OneRRule newNumericRule(Attribute attr, Instances data, int[] missingValueCounts) throws Exception Create a rule branching on this numeric attribute- Parameters:
attr- the attribute to branch ondata- the data to be used for creating the rulemissingValueCounts- to be filled in- Returns:
- the generated rule
- Throws:
Exception- if the rule can't be built successfully
-
listOptions
Returns an enumeration describing the available options..- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classAbstractClassifier- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-B <minimum bucket size> The minimum number of objects in a bucket (default: 6).
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classAbstractClassifier- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
Gets the current settings of the OneR classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classAbstractClassifier- Returns:
- an array of strings suitable for passing to setOptions
-
toSource
Returns a string that describes the classifier as source. The classifier will be contained in a class with the given name (there may be auxiliary classes), and will contain a method with the signature:
where the arraypublic static double classify(Object[] i);icontains elements that are either Double, String, with missing values represented as null. The generated code is public domain and comes with no warranty. -
toString
Returns a description of the classifier -
minBucketSizeTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMinBucketSize
public int getMinBucketSize()Get the value of minBucketSize.- Returns:
- Value of minBucketSize.
-
setMinBucketSize
public void setMinBucketSize(int v) Set the value of minBucketSize.- Parameters:
v- Value to assign to minBucketSize.
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
main
Main method for testing this class- Parameters:
argv- the commandline options
-