Package org.apache.spark.ml.attribute
Class NominalAttribute
Object
org.apache.spark.ml.attribute.Attribute
org.apache.spark.ml.attribute.NominalAttribute
- All Implemented Interfaces:
Serializable
A nominal attribute.
param: name optional name
param: index optional index
param: isOrdinal whether this attribute is ordinal (optional)
param: numValues optional number of values. At most one of
numValues
and values
can be
defined.
param: values optional values. At most one of numValues
and values
can be defined.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionattrType()
Attribute type.static final NominalAttribute
The default nominal attribute.boolean
static Attribute
fromStructField
(StructField field) scala.Option<Object>
Get the number of values, either fromnumValues
or fromvalues
.getValue
(int index) Gets a value given its index.int
hashCode()
boolean
Tests whether this attribute contains a specific value.scala.Option<Object>
index()
Index of the attribute.int
Index of a specific value.boolean
Tests whether this attribute is nominal, true forNominalAttribute
andBinaryAttribute
.boolean
Tests whether this attribute is numeric, true forNumericAttribute
andBinaryAttribute
.scala.Option<Object>
scala.Option<String>
name()
Name of the attribute.scala.Option<Object>
scala.Option<String[]>
values()
withIndex
(int index) Copy with a new index.Copy with a new name.withNumValues
(int numValues) Copy with a newnumValues
and emptyvalues
.Copy without the index.Copy without the name.Copy without thenumValues
.Copy without the values.withValues
(String[] values) Copy with new values and emptynumValues
.withValues
(String first, String... others) Copy with new values and emptynumValues
.withValues
(String first, scala.collection.immutable.Seq<String> others) Copy with new values and emptynumValues
.Methods inherited from class org.apache.spark.ml.attribute.Attribute
toMetadata, toMetadata, toString, toStructField, toStructField
-
Method Details
-
defaultAttr
The default nominal attribute. -
fromStructField
-
withValues
Copy with new values and emptynumValues
.- Parameters:
first
- (undocumented)others
- (undocumented)- Returns:
- (undocumented)
-
name
Description copied from class:Attribute
Name of the attribute. None if it is not set. -
index
Description copied from class:Attribute
Index of the attribute. None if it is not set. -
isOrdinal
-
numValues
-
values
-
attrType
Description copied from class:Attribute
Attribute type. -
isNumeric
public boolean isNumeric()Description copied from class:Attribute
Tests whether this attribute is numeric, true forNumericAttribute
andBinaryAttribute
. -
isNominal
public boolean isNominal()Description copied from class:Attribute
Tests whether this attribute is nominal, true forNominalAttribute
andBinaryAttribute
. -
indexOf
Index of a specific value. -
hasValue
Tests whether this attribute contains a specific value. -
getValue
Gets a value given its index. -
withName
Description copied from class:Attribute
Copy with a new name. -
withoutName
Description copied from class:Attribute
Copy without the name.- Specified by:
withoutName
in classAttribute
-
withIndex
Description copied from class:Attribute
Copy with a new index. -
withoutIndex
Description copied from class:Attribute
Copy without the index.- Specified by:
withoutIndex
in classAttribute
-
withValues
Copy with new values and emptynumValues
.- Parameters:
values
- (undocumented)- Returns:
- (undocumented)
-
withValues
Copy with new values and emptynumValues
.- Parameters:
first
- (undocumented)others
- (undocumented)- Returns:
- (undocumented)
-
withoutValues
Copy without the values. -
withNumValues
Copy with a newnumValues
and emptyvalues
.- Parameters:
numValues
- (undocumented)- Returns:
- (undocumented)
-
withoutNumValues
Copy without thenumValues
.- Returns:
- (undocumented)
-
getNumValues
Get the number of values, either fromnumValues
or fromvalues
. Return None if unknown.- Returns:
- (undocumented)
-
equals
-
hashCode
public int hashCode()
-