📄 capabilities.java
字号:
return result; } /** * sets the owner of this capabilities object * * @param value the new owner */ public void setOwner(CapabilitiesHandler value) { m_Owner = value; } /** * returns the owner of this capabilities object * * @return the current owner of this capabilites object */ public CapabilitiesHandler getOwner() { return m_Owner; } /** * sets the minimum number of instances that have to be in the dataset * * @param value the minimum number of instances */ public void setMinimumNumberInstances(int value) { if (value >= 0) m_MinimumNumberInstances = value; } /** * returns the minimum number of instances that have to be in the dataset * * @return the minimum number of instances */ public int getMinimumNumberInstances() { return m_MinimumNumberInstances; } /** * Returns an Iterator over the stored capabilities * * @return iterator over the current capabilities */ public Iterator capabilities() { return m_Capabilities.iterator(); } /** * Returns an Iterator over the stored dependencies * * @return iterator over the current dependencies */ public Iterator dependencies() { return m_Dependencies.iterator(); } /** * enables the given capability. * Enabling NOMINAL_ATTRIBUTES also enables BINARY_ATTRIBUTES, * UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. * Enabling BINARY_ATTRIBUTES also enables UNARY_ATTRIBUTES and * EMPTY_NOMINAL_ATTRIBUTES. * Enabling UNARY_ATTRIBUTES also enables EMPTY_NOMINAL_ATTRIBUTES. * But NOMINAL_CLASS only enables BINARY_CLASS, since normal schemes in Weka * don't work with datasets that have only 1 class label (or none). * * @param c the capability to enable */ public void enable(Capability c) { // attributes if (c == Capability.NOMINAL_ATTRIBUTES) { enable(Capability.BINARY_ATTRIBUTES); } else if (c == Capability.BINARY_ATTRIBUTES) { enable(Capability.UNARY_ATTRIBUTES); } else if (c == Capability.UNARY_ATTRIBUTES) { enable(Capability.EMPTY_NOMINAL_ATTRIBUTES); } // class else if (c == Capability.NOMINAL_CLASS) { enable(Capability.BINARY_CLASS); } m_Capabilities.add(c); } /** * enables the dependency flag for the given capability * Enabling NOMINAL_ATTRIBUTES also enables BINARY_ATTRIBUTES, * UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. * Enabling BINARY_ATTRIBUTES also enables UNARY_ATTRIBUTES and * EMPTY_NOMINAL_ATTRIBUTES. * Enabling UNARY_ATTRIBUTES also enables EMPTY_NOMINAL_ATTRIBUTES. * But NOMINAL_CLASS only enables BINARY_CLASS, since normal schemes in Weka * don't work with datasets that have only 1 class label (or none). * * @param c the capability to enable the dependency flag for */ public void enableDependency(Capability c) { // attributes if (c == Capability.NOMINAL_ATTRIBUTES) { enableDependency(Capability.BINARY_ATTRIBUTES); } else if (c == Capability.BINARY_ATTRIBUTES) { enableDependency(Capability.UNARY_ATTRIBUTES); } else if (c == Capability.UNARY_ATTRIBUTES) { enableDependency(Capability.EMPTY_NOMINAL_ATTRIBUTES); } // class else if (c == Capability.NOMINAL_CLASS) { enableDependency(Capability.BINARY_CLASS); } m_Dependencies.add(c); } /** * enables all class types * * @see #disableAllClasses() * @see #getClassCapabilities() */ public void enableAllClasses() { for (Capability cap: Capability.values()) { if (cap.isClass()) enable(cap); } } /** * enables all class type dependencies * * @see #disableAllClassDependencies() * @see #getClassCapabilities() */ public void enableAllClassDependencies() { for (Capability cap: Capability.values()) { if (cap.isClass()) enableDependency(cap); } } /** * enables all attribute types * * @see #disableAllAttributes() * @see #getAttributeCapabilities() */ public void enableAllAttributes() { for (Capability cap: Capability.values()) { if (cap.isAttribute()) enable(cap); } } /** * enables all attribute type dependencies * * @see #disableAllAttributeDependencies() * @see #getAttributeCapabilities() */ public void enableAllAttributeDependencies() { for (Capability cap: Capability.values()) { if (cap.isAttribute()) enableDependency(cap); } } /** * disables the given capability * Disabling NOMINAL_ATTRIBUTES also disables BINARY_ATTRIBUTES, * UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. * Disabling BINARY_ATTRIBUTES also disables UNARY_ATTRIBUTES and * EMPTY_NOMINAL_ATTRIBUTES. * Disabling UNARY_ATTRIBUTES also disables EMPTY_NOMINAL_ATTRIBUTES. * The same hierarchy applies to the class capabilities. * * @param c the capability to disable */ public void disable(Capability c) { // attributes if (c == Capability.NOMINAL_ATTRIBUTES) { disable(Capability.BINARY_ATTRIBUTES); } else if (c == Capability.BINARY_ATTRIBUTES) { disable(Capability.UNARY_ATTRIBUTES); } else if (c == Capability.UNARY_ATTRIBUTES) { disable(Capability.EMPTY_NOMINAL_ATTRIBUTES); } // class else if (c == Capability.NOMINAL_CLASS) { disable(Capability.BINARY_CLASS); } else if (c == Capability.BINARY_CLASS) { disable(Capability.UNARY_CLASS); } else if (c == Capability.UNARY_CLASS) { disable(Capability.EMPTY_NOMINAL_CLASS); } m_Capabilities.remove(c); } /** * disables the dependency of the given capability * Disabling NOMINAL_ATTRIBUTES also disables BINARY_ATTRIBUTES, * UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. * Disabling BINARY_ATTRIBUTES also disables UNARY_ATTRIBUTES and * EMPTY_NOMINAL_ATTRIBUTES. * Disabling UNARY_ATTRIBUTES also disables EMPTY_NOMINAL_ATTRIBUTES. * The same hierarchy applies to the class capabilities. * * @param c the capability to disable the dependency flag for */ public void disableDependency(Capability c) { // attributes if (c == Capability.NOMINAL_ATTRIBUTES) { disableDependency(Capability.BINARY_ATTRIBUTES); } else if (c == Capability.BINARY_ATTRIBUTES) { disableDependency(Capability.UNARY_ATTRIBUTES); } else if (c == Capability.UNARY_ATTRIBUTES) { disableDependency(Capability.EMPTY_NOMINAL_ATTRIBUTES); } // class else if (c == Capability.NOMINAL_CLASS) { disableDependency(Capability.BINARY_CLASS); } else if (c == Capability.BINARY_CLASS) { disableDependency(Capability.UNARY_CLASS); } else if (c == Capability.UNARY_CLASS) { disableDependency(Capability.EMPTY_NOMINAL_CLASS); } m_Dependencies.remove(c); } /** * disables all class types * * @see #enableAllClasses() * @see #getClassCapabilities() */ public void disableAllClasses() { for (Capability cap: Capability.values()) { if (cap.isClass()) disable(cap); } } /** * disables all class type dependencies * * @see #enableAllClassDependencies() * @see #getClassCapabilities() */ public void disableAllClassDependencies() { for (Capability cap: Capability.values()) { if (cap.isClass()) disableDependency(cap); } } /** * disables all attribute types * * @see #enableAllAttributes() * @see #getAttributeCapabilities() */ public void disableAllAttributes() { for (Capability cap: Capability.values()) { if (cap.isAttribute()) disable(cap); } } /** * disables all attribute type dependencies * * @see #enableAllAttributeDependencies() * @see #getAttributeCapabilities() */ public void disableAllAttributeDependencies() { for (Capability cap: Capability.values()) { if (cap.isAttribute()) disableDependency(cap); } } /** * returns all class capabilities * * @return all capabilities regarding the class * @see #enableAllClasses() * @see #disableAllClasses() */ public Capabilities getClassCapabilities() { Capabilities result; result = new Capabilities(getOwner()); for (Capability cap: Capability.values()) { if (cap.isClassCapability()) { if (handles(cap)) result.enable(cap); } } return result; } /** * returns all attribute capabilities * * @return all capabilities regarding attributes * @see #enableAllAttributes() * @see #disableAllAttributes() */ public Capabilities getAttributeCapabilities() { Capabilities result; result = new Capabilities(getOwner()); for (Capability cap: Capability.values()) { if (cap.isAttributeCapability()) { if (handles(cap)) result.enable(cap); } } return result; } /** * returns all other capabilities, besides class and attribute related ones * * @return all other capabilities, besides class and attribute * related ones */ public Capabilities getOtherCapabilities() { Capabilities result; result = new Capabilities(getOwner()); for (Capability cap: Capability.values()) { if (cap.isOtherCapability()) { if (handles(cap)) result.enable(cap); } } return result; } /** * returns true if the classifier handler has the specified capability * * @param c the capability to test * @return true if the classifier handler has the capability */ public boolean handles(Capability c) { return m_Capabilities.contains(c); } /** * returns true if the classifier handler has a dependency for the specified * capability * * @param c the capability to test * @return true if the classifier handler has a dependency for the * capability */ public boolean hasDependency(Capability c) { return m_Dependencies.contains(c); } /** * Checks whether there are any dependencies at all * * @return true if there is at least one dependency for a capability */ public boolean hasDependencies() { return (m_Dependencies.size() > 0); } /** * returns the reason why the tests failed, is null if tests succeeded * * @return the reason why the tests failed */ public Exception getFailReason() { return m_FailReason; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -