|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.core.Capabilities
public class Capabilities
A class that describes the capabilites (e.g., handling certain types of attributes, missing values, types of classes, etc.) of a specific classifier. By default, the classifier is capable of nothing. This ensures that new features have to be enabled explicitly.
A common code fragment for making use of the capabilities in a classifier would be this:
public void buildClassifier(Instances instances) throws Exception {
// can the classifier handle the data?
getCapabilities().testWithFail(instances);
...
// possible deletion of instances with missing class labels, etc.
For only testing a single attribute, use this:
... Attribute att = instances.attribute(0); getCapabilities().testWithFail(att); ...Or for testing the class attribute (uses the capabilities that are especially for the class):
... Attribute att = instances.classAttribute(); getCapabilities().testWithFail(att, true); ...
| Nested Class Summary | |
|---|---|
static class |
Capabilities.Capability
enumeration of all capabilities |
| Field Summary | |
|---|---|
static java.lang.String |
PROPERTIES_FILE
the properties file for managing the tests |
| Constructor Summary | |
|---|---|
Capabilities(CapabilitiesHandler owner)
initializes the capabilities for the given owner |
|
| Method Summary | |
|---|---|
void |
and(Capabilities c)
performs an AND conjunction with the capabilities of the given Capabilities object and updates itself |
void |
assign(Capabilities c)
retrieves the data from the given Capabilities object |
java.util.Iterator |
capabilities()
Returns an Iterator over the stored capabilities |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
java.util.Iterator |
dependencies()
Returns an Iterator over the stored dependencies |
void |
disable(Capabilities.Capability c)
disables the given capability Disabling NOMINAL_ATTRIBUTES also disables BINARY_ATTRIBUTES, UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. |
void |
disableAll()
disables all attribute and class types (including dependencies) |
void |
disableAllAttributeDependencies()
disables all attribute type dependencies |
void |
disableAllAttributes()
disables all attribute types |
void |
disableAllClassDependencies()
disables all class type dependencies |
void |
disableAllClasses()
disables all class types |
void |
disableDependency(Capabilities.Capability c)
disables the dependency of the given capability Disabling NOMINAL_ATTRIBUTES also disables BINARY_ATTRIBUTES, UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. |
void |
enable(Capabilities.Capability c)
enables the given capability. |
void |
enableAll()
enables all attribute and class types (including dependencies) |
void |
enableAllAttributeDependencies()
enables all attribute type dependencies |
void |
enableAllAttributes()
enables all attribute types |
void |
enableAllClassDependencies()
enables all class type dependencies |
void |
enableAllClasses()
enables all class types |
void |
enableDependency(Capabilities.Capability c)
enables the dependency flag for the given capability Enabling NOMINAL_ATTRIBUTES also enables BINARY_ATTRIBUTES, UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. |
static Capabilities |
forInstances(Instances data)
returns a Capabilities object specific for this data. |
static Capabilities |
forInstances(Instances data,
boolean multi)
returns a Capabilities object specific for this data. |
Capabilities |
getAttributeCapabilities()
returns all attribute capabilities |
Capabilities |
getClassCapabilities()
returns all class capabilities |
java.lang.Exception |
getFailReason()
returns the reason why the tests failed, is null if tests succeeded |
int |
getMinimumNumberInstances()
returns the minimum number of instances that have to be in the dataset |
Capabilities |
getOtherCapabilities()
returns all other capabilities, besides class and attribute related ones |
CapabilitiesHandler |
getOwner()
returns the owner of this capabilities object |
java.lang.String |
getRevision()
Returns the revision string. |
boolean |
handles(Capabilities.Capability c)
returns true if the classifier handler has the specified capability |
boolean |
hasDependencies()
Checks whether there are any dependencies at all |
boolean |
hasDependency(Capabilities.Capability c)
returns true if the classifier handler has a dependency for the specified capability |
static void |
main(java.lang.String[] args)
loads the given dataset and prints the Capabilities necessary to process it. |
void |
or(Capabilities c)
performs an OR conjunction with the capabilities of the given Capabilities object and updates itself |
void |
setMinimumNumberInstances(int value)
sets the minimum number of instances that have to be in the dataset |
void |
setOwner(CapabilitiesHandler value)
sets the owner of this capabilities object |
boolean |
supports(Capabilities c)
Returns true if the currently set capabilities support at least all of the capabiliites of the given Capabilities object (checks only the enum!) |
boolean |
supportsMaybe(Capabilities c)
Returns true if the currently set capabilities support (or have a dependency) at least all of the capabilities of the given Capabilities object (checks only the enum!) |
boolean |
test(Attribute att)
Test the given attribute, whether it can be processed by the handler, given its capabilities. |
boolean |
test(Attribute att,
boolean isClass)
Test the given attribute, whether it can be processed by the handler, given its capabilities. |
boolean |
test(Instances data)
Tests the given data, whether it can be processed by the handler, given its capabilities. |
boolean |
test(Instances data,
int fromIndex,
int toIndex)
Tests a certain range of attributes of the given data, whether it can be processed by the handler, given its capabilities. |
void |
testWithFail(Attribute att)
tests the given attribute by calling the test(Attribute,boolean) method and throws an exception if the test fails. |
void |
testWithFail(Attribute att,
boolean isClass)
tests the given attribute by calling the test(Attribute,boolean) method and throws an exception if the test fails. |
void |
testWithFail(Instances data)
tests the given data by calling the test(Instances) method and throws an exception if the test fails. |
void |
testWithFail(Instances data,
int fromIndex,
int toIndex)
tests the given data by calling the test(Instances,int,int) method and throws an exception if the test fails. |
java.lang.String |
toSource(java.lang.String objectname)
turns the capabilities object into source code. |
java.lang.String |
toSource(java.lang.String objectname,
int indent)
turns the capabilities object into source code. |
java.lang.String |
toString()
returns a string representation of the capabilities |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PROPERTIES_FILE
| Constructor Detail |
|---|
public Capabilities(CapabilitiesHandler owner)
owner - the object that produced this Capabilities instance| Method Detail |
|---|
public java.lang.Object clone()
clone in class java.lang.Objectpublic void assign(Capabilities c)
c - the capabilities object to initialize withpublic void and(Capabilities c)
c - the capabilities to AND withpublic void or(Capabilities c)
c - the capabilities to OR withpublic boolean supports(Capabilities c)
c - the capabilities to support at least
public boolean supportsMaybe(Capabilities c)
c - the capabilities (or dependencies) to support at least
public void setOwner(CapabilitiesHandler value)
value - the new ownerpublic CapabilitiesHandler getOwner()
public void setMinimumNumberInstances(int value)
value - the minimum number of instancespublic int getMinimumNumberInstances()
public java.util.Iterator capabilities()
public java.util.Iterator dependencies()
public void enable(Capabilities.Capability c)
c - the capability to enablepublic void enableDependency(Capabilities.Capability c)
c - the capability to enable the dependency flag forpublic void enableAllClasses()
disableAllClasses(),
getClassCapabilities()public void enableAllClassDependencies()
disableAllClassDependencies(),
getClassCapabilities()public void enableAllAttributes()
disableAllAttributes(),
getAttributeCapabilities()public void enableAllAttributeDependencies()
disableAllAttributeDependencies(),
getAttributeCapabilities()public void enableAll()
public void disable(Capabilities.Capability c)
c - the capability to disablepublic void disableDependency(Capabilities.Capability c)
c - the capability to disable the dependency flag forpublic void disableAllClasses()
enableAllClasses(),
getClassCapabilities()public void disableAllClassDependencies()
enableAllClassDependencies(),
getClassCapabilities()public void disableAllAttributes()
enableAllAttributes(),
getAttributeCapabilities()public void disableAllAttributeDependencies()
enableAllAttributeDependencies(),
getAttributeCapabilities()public void disableAll()
public Capabilities getClassCapabilities()
enableAllClasses(),
disableAllClasses()public Capabilities getAttributeCapabilities()
enableAllAttributes(),
disableAllAttributes()public Capabilities getOtherCapabilities()
public boolean handles(Capabilities.Capability c)
c - the capability to test
public boolean hasDependency(Capabilities.Capability c)
c - the capability to test
public boolean hasDependencies()
public java.lang.Exception getFailReason()
public boolean test(Attribute att)
att - the attribute to test
test(Attribute, boolean)
public boolean test(Attribute att,
boolean isClass)
att - the attribute to testisClass - whether this attribute is the class attribute
m_AttributeTestpublic boolean test(Instances data)
MultiInstanceCapabilitiesHandler interface are checked
automatically for their multi-instance Capabilities (if no bags, then
only the bag-structure, otherwise only the first bag).
data - the data to test
test(Instances, int, int)
public boolean test(Instances data,
int fromIndex,
int toIndex)
MultiInstanceCapabilitiesHandler interface
are checked automatically for their multi-instance Capabilities (if no
bags, then only the bag-structure, otherwise only the first bag).
data - the data to testfromIndex - the range of attributes - start (incl.)toIndex - the range of attributes - end (incl.)
MultiInstanceCapabilitiesHandler,
m_InstancesTest,
m_MissingValuesTest,
m_MissingClassValuesTest,
m_MinimumNumberInstancesTest
public void testWithFail(Attribute att)
throws java.lang.Exception
att - the attribute to test
java.lang.Exception - in case the attribute doesn't pass the teststest(Attribute,boolean)
public void testWithFail(Attribute att,
boolean isClass)
throws java.lang.Exception
att - the attribute to testisClass - whether this attribute is the class attribute
java.lang.Exception - in case the attribute doesn't pass the teststest(Attribute,boolean)
public void testWithFail(Instances data,
int fromIndex,
int toIndex)
throws java.lang.Exception
data - the data to testfromIndex - the range of attributes - start (incl.)toIndex - the range of attributes - end (incl.)
java.lang.Exception - in case the data doesn't pass the teststest(Instances,int,int)
public void testWithFail(Instances data)
throws java.lang.Exception
data - the data to test
java.lang.Exception - in case the data doesn't pass the teststest(Instances)public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toSource(java.lang.String objectname)
objectname - the name of the Capabilities object being instantiated
public java.lang.String toSource(java.lang.String objectname,
int indent)
objectname - the name of the Capabilities object being instantiatedindent - the number of blanks to indent
public static Capabilities forInstances(Instances data)
throws java.lang.Exception
data - the data to base the capabilities on
java.lang.Exception - in case an error occurrs, e.g., an unknown attribute
type
public static Capabilities forInstances(Instances data,
boolean multi)
throws java.lang.Exception
data - the data to base the capabilities onmulti - if true then the structure is checked, too
java.lang.Exception - in case an error occurrs, e.g., an unknown attribute
type
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - the commandline arguments
java.lang.Exception - if something goes wrongpublic java.lang.String getRevision()
getRevision in interface RevisionHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||