Package smile.data.measure
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
ConstructorDescriptionCategoricalMeasure
(int[] values) Constructor.CategoricalMeasure
(int[] values, String[] levels) Constructor.CategoricalMeasure
(String... levels) Constructor.CategoricalMeasure
(List<String> levels) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
factor
(int value) Returns the factor value (in range [0, size)) of level.level
(int value) Returns the level string representation.String[]
levels()
Returns the levels.int
size()
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
Constructor.- Parameters:
levels
- the levels of discrete values.
-
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
Returns the levels.- Returns:
- the levels.
-
level
Returns the level string representation.- Parameters:
value
- the level value.- Returns:
- the level string representation.
-
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
Description copied from interface:Measure
Returns the string representation of an object in the measure. -
valueOf
Description copied from interface:Measure
Returns a measurement value object represented by the argument string s. -
equals
-