Class NominalAttribute

Object
org.apache.spark.ml.attribute.Attribute
org.apache.spark.ml.attribute.NominalAttribute
All Implemented Interfaces:
Serializable, scala.Serializable

public class NominalAttribute extends Attribute
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 Details

    • defaultAttr

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

      public static Attribute fromStructField(StructField field)
    • withValues

      public NominalAttribute withValues(String first, String... others)
      Copy with new values and empty numValues.
      Parameters:
      first - (undocumented)
      others - (undocumented)
      Returns:
      (undocumented)
    • 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.
      Parameters:
      values - (undocumented)
      Returns:
      (undocumented)
    • withValues

      public NominalAttribute withValues(String first, scala.collection.Seq<String> others)
      Copy with new values and empty numValues.
      Parameters:
      first - (undocumented)
      others - (undocumented)
      Returns:
      (undocumented)
    • withoutValues

      public NominalAttribute withoutValues()
      Copy without the values.
    • withNumValues

      public NominalAttribute withNumValues(int numValues)
      Copy with a new numValues and empty values.
      Parameters:
      numValues - (undocumented)
      Returns:
      (undocumented)
    • withoutNumValues

      public NominalAttribute withoutNumValues()
      Copy without the numValues.
      Returns:
      (undocumented)
    • 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