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.Serializable
Generic 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 class
Attribute.Type
The 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 boolean
equals(java.lang.Object o)
java.lang.String
getDescription()
java.lang.String
getName()
Attribute.Type
getType()
double
getWeight()
int
hashCode()
Attribute
setDescription(java.lang.String description)
Attribute
setName(java.lang.String name)
Attribute
setWeight(double weight)
java.lang.String
toString()
abstract java.lang.String
toString(double x)
Returns the string representation of a double value of this attribute.abstract double
valueOf(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.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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-