public class Capabilities extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, RevisionHandler
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); ...
Modifier and Type | Class and Description |
---|---|
static class |
Capabilities.Capability
enumeration of all capabilities
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTIES_FILE
the properties file for managing the tests
|
Constructor and Description |
---|
Capabilities(CapabilitiesHandler owner)
initializes the capabilities for the given owner
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addCapabilities(java.lang.String title)
generates a string from the capabilities, suitable to add to the help
text.
|
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.Capability> |
capabilities()
Returns an Iterator over the stored capabilities
|
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
java.util.Iterator<Capabilities.Capability> |
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.
|
boolean |
doNotCheckCapabilities()
Does owner implement CapabilitiesIgnorer and does it not
want capability checking to be performed?
|
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
|
java.lang.String |
listCapabilities()
returns a comma-separated list of all the capabilities, excluding interface-based ones.
|
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
capabilities 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
|
public static final java.lang.String PROPERTIES_FILE
public Capabilities(CapabilitiesHandler owner)
owner
- the object that produced this Capabilities instancepublic boolean doNotCheckCapabilities()
public java.lang.Object clone()
clone
in class java.lang.Object
public 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 leastpublic boolean supportsMaybe(Capabilities c)
c
- the capabilities (or dependencies) to support at leastpublic 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.Capability> capabilities()
public java.util.Iterator<Capabilities.Capability> 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()
public void enableAllAttributes()
disableAllAttributes()
,
getAttributeCapabilities()
public void enableAllAttributeDependencies()
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()
public void disableAllAttributes()
enableAllAttributes()
,
getAttributeCapabilities()
public void disableAllAttributeDependencies()
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 testpublic boolean hasDependency(Capabilities.Capability c)
c
- the capability to testpublic boolean hasDependencies()
public java.lang.Exception getFailReason()
public boolean test(Attribute att)
att
- the attribute to testtest(Attribute, boolean)
public boolean test(Attribute att, boolean isClass)
att
- the attribute to testisClass
- whether this attribute is the class attributem_AttributeTest
public 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 testtest(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 testjava.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 attributejava.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 testjava.lang.Exception
- in case the data doesn't pass the teststest(Instances)
public java.lang.String listCapabilities()
public java.lang.String addCapabilities(java.lang.String title)
title
- the title for the capabilitiespublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toSource(java.lang.String objectname)
objectname
- the name of the Capabilities object being instantiatedpublic java.lang.String toSource(java.lang.String objectname, int indent)
objectname
- the name of the Capabilities object being instantiatedindent
- the number of blanks to indentpublic static Capabilities forInstances(Instances data) throws java.lang.Exception
data
- the data to base the capabilities onjava.lang.Exception
- in case an error occurrs, e.g., an unknown attribute typepublic 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, toojava.lang.Exception
- in case an error occurrs, e.g., an unknown attribute typepublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- the commandline argumentsjava.lang.Exception
- if something goes wrongpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler