|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.meta.HND
Class to create levelwise NDs with respect to a given hierarchy of classes. Valid options are:
-P classname
Specify the full class name of a ClassHierarchyParser
(default: weka.core.converters.ClassTreeArffFileParser
).
-H classHierarchy
A String specifying the class-hierarchy in a valid manner
with respect to the specified ClassHierarchyParser (required).
-L property-file
A String specifying the filename providing levelwise options
for the respective ND and for selection of attributes (optional).
A key for ND options is supposed to be of form
"leveln" for level n.
Levelwise properties will overwrite the general options for ND
or select attributes for the respective level only.
A key for levelwise selection of attributes is supposed to be
of form "removen" for level n.
The property for this key is supposed to be a string
providing the options for the Filter
Remove
.
Options after "--" are passed to the inherent NDs.
Field Summary | |
private java.util.Map |
childrenHNDs
The HNDs covering the instances at deeper levels, if there are such. |
private ClassHierarchyParser |
classHierarchyParser
The default parser is a ClassTreeArffFileParser, suitable for a hierarchy encoded within a single String. |
private ClassHierarchy |
hierarchy
The hierarchy of classes for the current and deeper levels. |
private int |
LEVEL
The level of this HND in the hierarchy (root is 0). |
static java.lang.String |
LEVEL_PROPERTY
Key-prefix for the property level. |
private ND |
nd
The ND to classify the instances at the currentlevel |
private java.lang.String[] |
ndOptions
The options to be set for each ND. |
private java.util.Properties |
properties
The properties for levelwise settings of the respective ND. |
private java.lang.String |
propertyFilename
The filename of the property-file as set via setOptions. |
static java.lang.String |
REMOVE_FILTER_PROPERTY
Key-prefix for the property filter, for levelwise selection of attributes. |
static java.util.regex.Pattern |
WHITESPACE
The pattern for separation of entries in the option-line of a property-file. |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
|
HND()
Default constructor creates a HND without hierarchy for level 0. |
private |
HND(ClassHierarchy hierarchy,
java.util.Properties properties,
int level)
The constructor to be used by the buildLevelwiseClassifier(Instances)
method provides a hierarchy. |
Method Summary | |
private void |
appendDescription(java.lang.StringBuffer description)
Appends a description of all children HNDs of this HND to the given description. |
void |
buildClassifier(Instances data)
Builds the classifier for the given training data. |
private void |
buildLevelwiseClassifier(Instances data)
Build levelwise NDs with respect to the specified hierarchy of classes. |
double[] |
distributionForInstance(Instance instance)
Returns a class probability estimation for the given instance. |
private void |
distributionForInstance(Instance instance,
java.util.Map classDistribution,
double factor)
Computes levelwise class probability estimation for the given instance and fills in the respective values to the classDistribution, using the factor (accumulated class probability for the respective superclass). |
java.lang.String[] |
getOptions()
Returns the current settings of the Classifier. |
int |
getSeed()
Returns the current seed of the ND. |
void |
initND(java.lang.String[] ndOptions)
Sets the given options to the ND. |
java.util.Enumeration |
listOptions()
Returns a list of the available options. |
static void |
main(java.lang.String[] args)
Main method for testing this class. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setSeed(int seed)
Sets the given seed to the ND and recursively to NDs of children HNDs. |
java.lang.String |
toString()
Returns a description of this classifier. |
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String LEVEL_PROPERTY
public static final java.lang.String REMOVE_FILTER_PROPERTY
public static final java.util.regex.Pattern WHITESPACE
private ND nd
private java.util.Properties properties
private java.lang.String propertyFilename
private final int LEVEL
private java.lang.String[] ndOptions
private java.util.Map childrenHNDs
private ClassHierarchy hierarchy
private ClassHierarchyParser classHierarchyParser
Constructor Detail |
public HND()
setOptions(String[]
or remains null,
in which case any data will be rejected as invalid.
private HND(ClassHierarchy hierarchy, java.util.Properties properties, int level)
buildLevelwiseClassifier(Instances)
method provides a hierarchy.
hierarchy
- the specified hierarchy for the respective levelproperties
- the levelwise properties to be setlevel
- the current level of the hierarchyMethod Detail |
public void initND(java.lang.String[] ndOptions) throws java.lang.Exception
ndOptions
- the options to be set to the ND.
The parameter ndOptions is copied, not altered,
since it is to be passed through all levels.
java.lang.Exception
- in case of invalid options for NDprivate void buildLevelwiseClassifier(Instances data) throws java.lang.Exception
data
- training instances
java.lang.Exception
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been
generated successfullyClassifier.buildClassifier(Instances)
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if distribution could not be
computed successfullyClassifier.distributionForInstance(weka.core.Instance)
private void distributionForInstance(Instance instance, java.util.Map classDistribution, double factor) throws java.lang.Exception
instance
- the instance to be classifiedclassDistribution
- the class distribution covering all classesfactor
- the class probability for the respective superclass
java.lang.Exception
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
OptionHandler.getOptions()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
OptionHandler.listOptions()
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-P classname
Specify the full class name of a ClassHierarchyParser
(default: weka.core.converters.ClassTreeArffFileParser
).
-H classHierarchy
A String specifying the class-hierarchy in a valid manner
with respect to the specified ClassHierarchyParser (required).
-L property-file
A String specifying the filename providing levelwise options
for the respective ND and for selection of attributes (optional).
A key for ND options is supposed to be of form
"leveln" for level n.
Levelwise properties will overwrite the general options for ND
or select attributes for the respective level only.
A key for levelwise selection of attributes is supposed to be
of form "removen" for level n.
The property for this key is supposed to be a string
providing the options for the Filter
Remove
.
Options after -- are passed to the inherent NDs.
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of strings
java.lang.Exception
- if a required option is not supportedOptionHandler.setOptions(java.lang.String[])
public void setSeed(int seed)
setSeed
in interface Randomizable
seed
- the seedRandomizable.setSeed(int)
public int getSeed()
getSeed
in interface Randomizable
Randomizable.getSeed()
public java.lang.String toString()
Object.toString()
private void appendDescription(java.lang.StringBuffer description)
description
- the description to which further descriptions are to be appendedpublic static void main(java.lang.String[] args)
args
- the options
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |