Package com.groiss.ml.ds
Class NominalAttribute<T>
java.lang.Object
com.groiss.ml.ds.Attribute<T>
com.groiss.ml.ds.NominalAttribute<T>
- Direct Known Subclasses:
BooleanAttribute
Attribute which value can be one of a given set of values.
-
Constructor Summary
ConstructorDescriptionNominalAttribute
(String name, Class<T> clazz, List<S> values) Creates a newNominalAttribute
.NominalAttribute
(String name, Class<T> clazz, S... values) Creates a newNominalAttribute
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkTypeCompatibility
(Object value) Returns the values supported by this attribute as ARFF stringint
getIndexOf
(Object value) Returns the index of the passed value within the values represented by this class.int
getIndexOfValueAsString
(String value) Returns the index of the value within the values represented by this class where the string representation of those values equals the given stringgetValueAt
(int index) Returns the value at the given index within the values of this attribute.Returns a list of the values supported by this attributeboolean
Returns true if the passed value is supported by this attribute (i.e. if it is part of the values defined by the constructor)
-
Constructor Details
-
NominalAttribute
Creates a newNominalAttribute
.- Parameters:
name
- the name of this attributeclazz
- the class of the values represented by this attributevalues
- the possible values for objects represented by this attribute
-
NominalAttribute
Creates a newNominalAttribute
.- Parameters:
name
- the name of this attributeclazz
- the class of the values represented by this attributevalues
- the possible values for objects represented by this attribute
-
-
Method Details
-
getARFFValues
Description copied from class:Attribute
Returns the values supported by this attribute as ARFF string- Specified by:
getARFFValues
in classAttribute<T>
- Returns:
- the supported values as ARFF string
-
getValueAt
Returns the value at the given index within the values of this attribute.- Parameters:
index
- the index of the wanted value- Returns:
- value of this attribute at given index
-
hasValue
Returns true if the passed value is supported by this attribute (i.e. if it is part of the values defined by the constructor)- Parameters:
value
- the requested value- Returns:
- true if this nominal attribute can represent the given value, false otherwise
- Throws:
ClassCastException
- if the type of the specified element is incompatible with this attribute
-
getIndexOf
Returns the index of the passed value within the values represented by this class.- Parameters:
value
- the requested value- Returns:
- index at which the given object is stored, or -1 if there is no such index
- Throws:
ClassCastException
- if the type of the specified element is incompatible with this attribute
-
checkTypeCompatibility
-
getIndexOfValueAsString
Returns the index of the value within the values represented by this class where the string representation of those values equals the given string- Parameters:
value
- the string representation of the requested value- Returns:
- index of value where the String representation equals the given String, or -1 if there is no such index
-
getValues
Returns a list of the values supported by this attribute- Returns:
- values a field in the column of this nominal attribute can become
-