Package smile.data
Class Attribute
- java.lang.Object
-
- smile.data.Attribute
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
DateAttribute,NominalAttribute,NumericAttribute
public abstract class Attribute extends java.lang.Object implements java.io.SerializableGeneric class to represent a named attribute/variable.- Author:
- Haifeng Li
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAttribute.TypeThe type of attributes.
-
Constructor Summary
Constructors Constructor Description Attribute(Attribute.Type type, java.lang.String name)Constructor.Attribute(Attribute.Type type, java.lang.String name, double weight)Constructor.Attribute(Attribute.Type type, java.lang.String name, java.lang.String description)Constructor.Attribute(Attribute.Type type, java.lang.String name, java.lang.String description, double weight)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetDescription()java.lang.StringgetName()Attribute.TypegetType()doublegetWeight()inthashCode()AttributesetDescription(java.lang.String description)AttributesetName(java.lang.String name)AttributesetWeight(double weight)java.lang.StringtoString()abstract java.lang.StringtoString(double x)Returns the string representation of a double value of this attribute.abstract doublevalueOf(java.lang.String s)Returns the double value of a string of this attribute.
-
-
-
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
-
getType
public Attribute.Type getType()
-
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.ParseExceptionReturns 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-