Package smile.data

Class Attribute

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    DateAttribute, NominalAttribute, NumericAttribute

    public abstract class Attribute
    extends java.lang.Object
    implements java.io.Serializable
    Generic class to represent a named attribute/variable.
    Author:
    Haifeng Li
    See Also:
    Serialized Form
    • Constructor Detail

      • Attribute

        public Attribute​(Attribute.Type type,
                         java.lang.String name)
        Constructor.
      • Attribute

        public Attribute​(Attribute.Type type,
                         java.lang.String name,
                         double weight)
        Constructor.
      • Attribute

        public Attribute​(Attribute.Type type,
                         java.lang.String name,
                         java.lang.String description)
        Constructor.
      • Attribute

        public Attribute​(Attribute.Type type,
                         java.lang.String name,
                         java.lang.String description,
                         double weight)
        Constructor.
    • Method Detail

      • getName

        public java.lang.String getName()
      • setName

        public Attribute setName​(java.lang.String name)
      • getDescription

        public java.lang.String getDescription()
      • setDescription

        public Attribute setDescription​(java.lang.String description)
      • getWeight

        public double getWeight()
      • setWeight

        public Attribute setWeight​(double weight)
      • toString

        public abstract java.lang.String toString​(double x)
        Returns the string representation of a double value of this 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.
      • valueOf

        public abstract double valueOf​(java.lang.String s)
                                throws java.text.ParseException
        Returns the double value of a string of this attribute.
        Parameters:
        s - a string value of this attribute.
        Throws:
        java.text.ParseException
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object