Class CategoricalMeasure
java.lang.Object
smile.data.measure.CategoricalMeasure
- All Implemented Interfaces:
Serializable, Measure
- Direct Known Subclasses:
NominalScale, OrdinalScale
Categorical data can be stored into groups or categories with the aid of
names or labels. Also known as qualitative data, each element of a
categorical data can be placed in only one category according to
its qualities, where each of the categories is mutually exclusive.
Categorical data may be subdivided into nominal data and ordinal data.
Both integer and string variables can be made into categorical measure, but a categorical measure's levels will always be string values.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCategoricalMeasure(int[] values) Constructor.CategoricalMeasure(int[] values, String[] levels) Constructor.CategoricalMeasure(String... levels) Constructor.CategoricalMeasure(List<String> levels) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int value) Returns true if this measure contains the given integer value.booleanReturns true if this measure contains the given level string.booleanintfactor(int value) Returns the factor value (in range [0, size)) of level.inthashCode()intReturns the ordinal index (0-based position in the levels array) of the given level string, or -1 if not found.level(int value) Returns the level string representation.String[]levels()Returns the levels.intsize()Returns the number of levels.toString(int value) Returns the string value of a level.Returns the string representation of an object in the measure.type()Returns the data type that is suitable for this measure scale.Returns a measurement value object represented by the argument string s.int[]values()Returns the valid value set.
-
Constructor Details
-
CategoricalMeasure
Constructor.- Parameters:
levels- the levels of discrete values.
-
CategoricalMeasure
-
CategoricalMeasure
public CategoricalMeasure(int[] values) Constructor.- Parameters:
values- the valid values.
-
CategoricalMeasure
Constructor.- Parameters:
values- the valid values.levels- the levels of discrete values.
-
-
Method Details
-
size
public int size()Returns the number of levels.- Returns:
- the number of levels.
-
values
public int[] values()Returns the valid value set.- Returns:
- the valid value set.
-
levels
-
level
Returns the level string representation.- Parameters:
value- the level value.- Returns:
- the level string representation, or null if not found.
-
contains
public boolean contains(int value) Returns true if this measure contains the given integer value.- Parameters:
value- the integer value to check.- Returns:
- true if value is a valid level code.
-
contains
Returns true if this measure contains the given level string.- Parameters:
level- the level string to check.- Returns:
- true if the level string is a valid level.
-
indexOf
Returns the ordinal index (0-based position in the levels array) of the given level string, or -1 if not found.- Parameters:
level- the level string.- Returns:
- the index in the levels array, or -1 if not found.
-
factor
public int factor(int value) Returns the factor value (in range [0, size)) of level.- Parameters:
value- the level value.- Returns:
- the factor value.
-
type
Returns the data type that is suitable for this measure scale.- Returns:
- the data type that is suitable for this measure scale.
-
toString
Returns the string value of a level.- Parameters:
value- the level value.- Returns:
- the string value of a level.
-
toString
-
valueOf
-
equals
-
hashCode
-