|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.core.Attribute
Class for handling an attribute. Once an attribute has been created, it can't be changed.
Three attribute types are supported:
...
// Create numeric attributes "length" and "weight"
Attribute length = new Attribute("length");
Attribute weight = new Attribute("weight");
// Create vector to hold nominal values "first", "second", "third"
FastVector my_nominal_values = new FastVector(3);
my_nominal_values.addElement("first");
my_nominal_values.addElement("second");
my_nominal_values.addElement("third");
// Create nominal attribute "position"
Attribute position = new Attribute("position", my_nominal_values);
...
Field Summary | |
static int |
DATE
Constant set for attributes with date values. |
static int |
NOMINAL
Constant set for nominal attributes. |
static int |
NUMERIC
Constant set for numeric attributes. |
static int |
ORDERING_MODULO
Constant set for modulo-ordered attributes. |
static int |
ORDERING_ORDERED
Constant set for ordered attributes. |
static int |
ORDERING_SYMBOLIC
Constant set for symbolic attributes. |
static int |
STRING
Constant set for attributes with string values. |
Constructor Summary | |
Attribute(java.lang.String attributeName)
Constructor for a numeric attribute. |
|
Attribute(java.lang.String attributeName,
FastVector attributeValues)
Constructor for nominal attributes and string attributes. |
|
Attribute(java.lang.String attributeName,
FastVector attributeValues,
ProtectedProperties metadata)
Constructor for nominal attributes and string attributes, where metadata is supplied. |
|
Attribute(java.lang.String attributeName,
ProtectedProperties metadata)
Constructor for a numeric attribute, where metadata is supplied. |
|
Attribute(java.lang.String attributeName,
java.lang.String dateFormat)
Constructor for a date attribute. |
|
Attribute(java.lang.String attributeName,
java.lang.String dateFormat,
ProtectedProperties metadata)
Constructor for a date attribute, where metadata is supplied. |
Method Summary | |
int |
addStringValue(Attribute src,
int index)
Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string. |
int |
addStringValue(java.lang.String value)
Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string. |
java.lang.Object |
copy()
Produces a shallow copy of this attribute. |
java.util.Enumeration |
enumerateValues()
Returns an enumeration of all the attribute's values if the attribute is nominal or a string, null otherwise. |
boolean |
equals(java.lang.Object other)
Tests if given attribute is equal to this attribute. |
java.lang.String |
formatDate(double date)
|
double |
getLowerNumericBound()
Returns the lower bound of a numeric attribute. |
ProtectedProperties |
getMetadata()
Returns the properties supplied for this attribute. |
double |
getUpperNumericBound()
Returns the upper bound of a numeric attribute. |
boolean |
hasZeropoint()
Returns whether the attribute has a zeropoint and may be added meaningfully. |
int |
index()
Returns the index of this attribute. |
int |
indexOfValue(java.lang.String value)
Returns the index of a given attribute value. |
boolean |
isAveragable()
Returns whether the attribute can be averaged meaningfully. |
boolean |
isDate()
Tests if the attribute is a date type. |
boolean |
isInRange(double value)
Determines whether a value lies within the bounds of the attribute. |
boolean |
isNominal()
Test if the attribute is nominal. |
boolean |
isNumeric()
Tests if the attribute is numeric. |
boolean |
isRegular()
Returns whether the attribute values are equally spaced. |
boolean |
isString()
Tests if the attribute is a string. |
boolean |
lowerNumericBoundIsOpen()
Returns whether the lower numeric bound of the attribute is open. |
static void |
main(java.lang.String[] ops)
Simple main method for testing this class. |
java.lang.String |
name()
Returns the attribute's name. |
int |
numValues()
Returns the number of attribute values. |
int |
ordering()
Returns the ordering of the attribute. |
double |
parseDate(java.lang.String string)
|
java.lang.String |
toString()
Returns a description of this attribute in ARFF format. |
int |
type()
Returns the attribute's type as an integer. |
boolean |
upperNumericBoundIsOpen()
Returns whether the upper numeric bound of the attribute is open. |
java.lang.String |
value(int valIndex)
Returns a value of a nominal or string attribute. |
double |
weight()
Returns the attribute's weight. |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NUMERIC
public static final int NOMINAL
public static final int STRING
public static final int DATE
public static final int ORDERING_SYMBOLIC
public static final int ORDERING_ORDERED
public static final int ORDERING_MODULO
Constructor Detail |
public Attribute(java.lang.String attributeName)
attributeName
- the name for the attributepublic Attribute(java.lang.String attributeName, ProtectedProperties metadata)
attributeName
- the name for the attributemetadata
- the attribute's propertiespublic Attribute(java.lang.String attributeName, java.lang.String dateFormat)
attributeName
- the name for the attributedateFormat
- a string suitable for use with
SimpleDateFormatter for parsing dates.public Attribute(java.lang.String attributeName, java.lang.String dateFormat, ProtectedProperties metadata)
attributeName
- the name for the attributedateFormat
- a string suitable for use with
SimpleDateFormatter for parsing dates.metadata
- the attribute's propertiespublic Attribute(java.lang.String attributeName, FastVector attributeValues)
attributeName
- the name for the attributeattributeValues
- a vector of strings denoting the
attribute values. Null if the attribute is a string attribute.public Attribute(java.lang.String attributeName, FastVector attributeValues, ProtectedProperties metadata)
attributeName
- the name for the attributeattributeValues
- a vector of strings denoting the
attribute values. Null if the attribute is a string attribute.metadata
- the attribute's propertiesMethod Detail |
public java.lang.Object copy()
copy
in interface Copyable
public final java.util.Enumeration enumerateValues()
public final boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the Object to be compared to this attribute
public final int index()
public final int indexOfValue(java.lang.String value)
value
- the value for which the index is to be returned
public final boolean isNominal()
public final boolean isNumeric()
public final boolean isString()
public final boolean isDate()
public final java.lang.String name()
public final int numValues()
public final java.lang.String toString()
toString
in class java.lang.Object
public final int type()
public final java.lang.String value(int valIndex)
valIndex
- the value's index
public int addStringValue(java.lang.String value)
value
- The string value to add
public int addStringValue(Attribute src, int index)
src
- The Attribute containing the string value to add.
public java.lang.String formatDate(double date)
public double parseDate(java.lang.String string) throws java.text.ParseException
java.text.ParseException
public final ProtectedProperties getMetadata()
public final int ordering()
public final boolean isRegular()
public final boolean isAveragable()
public final boolean hasZeropoint()
public final double weight()
public final double getLowerNumericBound()
public final boolean lowerNumericBoundIsOpen()
public final double getUpperNumericBound()
public final boolean upperNumericBoundIsOpen()
public final boolean isInRange(double value)
public static void main(java.lang.String[] ops)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London