Package smile.data

Class NominalAttribute

  • All Implemented Interfaces:
    java.io.Serializable

    public class NominalAttribute
    extends Attribute
    Nominal attribute. Nominal attributes are defined on a list of the unordered values.
    Author:
    Haifeng Li
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      NominalAttribute​(java.lang.String name)
      Constructor.
      NominalAttribute​(java.lang.String name, double weight)
      Constructor.
      NominalAttribute​(java.lang.String name, double weight, java.lang.String[] values)
      Constructor.
      NominalAttribute​(java.lang.String name, java.lang.String description)
      Constructor.
      NominalAttribute​(java.lang.String name, java.lang.String[] values)
      Constructor.
      NominalAttribute​(java.lang.String name, java.lang.String description, double weight)
      Constructor.
      NominalAttribute​(java.lang.String name, java.lang.String description, double weight, java.lang.String[] values)
      Constructor.
      NominalAttribute​(java.lang.String name, java.lang.String description, java.lang.String[] values)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isOpen()
      Returns true if the string values of the nominal attribute is a open set.
      void setOpen​(boolean open)
      Sets if the string values of the nominal attribute is a open set.
      int size()
      Returns the number of nominal values.
      java.lang.String toString​(double x)
      Returns the string representation of a double value of this attribute.
      double valueOf​(java.lang.String s)
      Returns the ordinal value of a string value.
      java.lang.String[] values()
      Returns the string values of nominal attribute.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NominalAttribute

        public NominalAttribute​(java.lang.String name)
        Constructor.
        Parameters:
        name - the name of attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                double weight)
        Constructor.
        Parameters:
        name - the name of attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                java.lang.String description)
        Constructor.
        Parameters:
        name - the name of attribute.
        description - the detailed description of attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                java.lang.String description,
                                double weight)
        Constructor.
        Parameters:
        name - the name of attribute.
        description - the detailed description of attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                java.lang.String[] values)
        Constructor.
        Parameters:
        name - the name of attribute.
        values - the valid string values of nominal attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                double weight,
                                java.lang.String[] values)
        Constructor.
        Parameters:
        name - the name of attribute.
        values - the valid string values of nominal attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                java.lang.String description,
                                java.lang.String[] values)
        Constructor.
        Parameters:
        name - the name of attribute.
        description - the detailed description of attribute.
        values - the valid string values of nominal attribute.
      • NominalAttribute

        public NominalAttribute​(java.lang.String name,
                                java.lang.String description,
                                double weight,
                                java.lang.String[] values)
        Constructor.
        Parameters:
        name - the name of attribute.
        description - the detailed description of attribute.
        values - the valid string values of nominal attribute.
    • Method Detail

      • size

        public int size()
        Returns the number of nominal values.
        Returns:
        the number of nominal values
      • isOpen

        public boolean isOpen()
        Returns true if the string values of the nominal attribute is a open set. The new string values will be added into the attribute when calling the method valueOf(String).
        Returns:
        true if the string values of the nominal attribute is a open set.
      • setOpen

        public void setOpen​(boolean open)
        Sets if the string values of the nominal attribute is a open set.
        Parameters:
        open - true if the string values of the nominal attribute is a open set.
      • values

        public java.lang.String[] values()
        Returns the string values of nominal attribute.
      • valueOf

        public double valueOf​(java.lang.String s)
                       throws java.text.ParseException
        Returns the ordinal value of a string value.
        Specified by:
        valueOf in class Attribute
        Parameters:
        s - a string value of this attribute.
        Throws:
        java.text.ParseException
      • toString

        public java.lang.String toString​(double x)
        Description copied from class: Attribute
        Returns the string representation of a double value of this attribute.
        Specified by:
        toString in class Attribute
        Parameters:
        x - a double value of this attribute. NaN means missing value.
        Returns:
        the string representation of x. For nominal, date and string attributes, null will be returned for missing values. For numeric attributes, "NaN" will be returned for missing values.