org.apache.spark.ml.attribute
Class NominalAttribute

Object
  extended by org.apache.spark.ml.attribute.Attribute
      extended by org.apache.spark.ml.attribute.NominalAttribute
All Implemented Interfaces:
java.io.Serializable

public class NominalAttribute
extends Attribute

:: DeveloperApi :: 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:
Serialized Form

Method Summary
 AttributeType attrType()
          Attribute type.
static NominalAttribute defaultAttr()
          The default nominal attribute.
 boolean equals(Object other)
           
 scala.Option<Object> getNumValues()
          Get the number of values, either from numValues or from values.
 String getValue(int index)
          Gets a value given its index.
 int hashCode()
           
 boolean hasValue(String value)
          Tests whether this attribute contains a specific value.
 scala.Option<Object> index()
          Index of the attribute.
 int indexOf(String value)
          Index of a specific value.
 boolean isNominal()
          Tests whether this attribute is nominal, true for NominalAttribute and BinaryAttribute.
 boolean isNumeric()
          Tests whether this attribute is numeric, true for NumericAttribute and BinaryAttribute.
 scala.Option<Object> isOrdinal()
           
 scala.Option<String> name()
          Name of the attribute.
 scala.Option<Object> numValues()
           
 scala.Option<String[]> values()
           
 NominalAttribute withIndex(int index)
          Copy with a new index.
 NominalAttribute withName(String name)
          Copy with a new name.
 NominalAttribute withNumValues(int numValues)
          Copy with a new `numValues` and empty `values`.
 NominalAttribute withoutIndex()
          Copy without the index.
 NominalAttribute withoutName()
          Copy without the name.
 NominalAttribute withoutNumValues()
          Copy without the `numValues`.
 NominalAttribute withoutValues()
          Copy without the values.
 NominalAttribute withValues(String[] values)
          Copy with new values and empty `numValues`.
 NominalAttribute withValues(String first, scala.collection.Seq<String> others)
          Copy with new values and empty `numValues`.
 NominalAttribute withValues(String first, String... others)
          Copy with new values and empty `numValues`.
 
Methods inherited from class org.apache.spark.ml.attribute.Attribute
toMetadata, toMetadata, toString, toStructField, toStructField
 
Methods inherited from class Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

defaultAttr

public static final NominalAttribute defaultAttr()
The default nominal attribute.


withValues

public NominalAttribute withValues(String first,
                                   String... others)
Copy with new values and empty `numValues`.


name

public scala.Option<String> name()
Description copied from class: Attribute
Name of the attribute. None if it is not set.

Specified by:
name in class Attribute

index

public scala.Option<Object> index()
Description copied from class: Attribute
Index of the attribute. None if it is not set.

Specified by:
index in class Attribute

isOrdinal

public scala.Option<Object> isOrdinal()

numValues

public scala.Option<Object> numValues()

values

public scala.Option<String[]> values()

attrType

public AttributeType attrType()
Description copied from class: Attribute
Attribute type.

Specified by:
attrType in class Attribute

isNumeric

public boolean isNumeric()
Description copied from class: Attribute
Tests whether this attribute is numeric, true for NumericAttribute and BinaryAttribute.

Specified by:
isNumeric in class Attribute
Returns:
(undocumented)

isNominal

public boolean isNominal()
Description copied from class: Attribute
Tests whether this attribute is nominal, true for NominalAttribute and BinaryAttribute.

Specified by:
isNominal in class Attribute
Returns:
(undocumented)

indexOf

public int indexOf(String value)
Index of a specific value.


hasValue

public boolean hasValue(String value)
Tests whether this attribute contains a specific value.


getValue

public String getValue(int index)
Gets a value given its index.


withName

public NominalAttribute withName(String name)
Description copied from class: Attribute
Copy with a new name.

Specified by:
withName in class Attribute

withoutName

public NominalAttribute withoutName()
Description copied from class: Attribute
Copy without the name.

Specified by:
withoutName in class Attribute

withIndex

public NominalAttribute withIndex(int index)
Description copied from class: Attribute
Copy with a new index.

Specified by:
withIndex in class Attribute

withoutIndex

public NominalAttribute withoutIndex()
Description copied from class: Attribute
Copy without the index.

Specified by:
withoutIndex in class Attribute

withValues

public NominalAttribute withValues(String[] values)
Copy with new values and empty `numValues`.


withValues

public NominalAttribute withValues(String first,
                                   scala.collection.Seq<String> others)
Copy with new values and empty `numValues`.


withoutValues

public NominalAttribute withoutValues()
Copy without the values.


withNumValues

public NominalAttribute withNumValues(int numValues)
Copy with a new `numValues` and empty `values`.


withoutNumValues

public NominalAttribute withoutNumValues()
Copy without the `numValues`.


getNumValues

public scala.Option<Object> getNumValues()
Get the number of values, either from numValues or from values. Return None if unknown.

Returns:
(undocumented)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object