Java Doc for Attribute.java in  » Science » weka » weka » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » weka » weka.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   weka.core.Attribute

Attribute
public class Attribute implements Copyable,Serializable(Code)
Class for handling an attribute. Once an attribute has been created, it can't be changed.

The following attribute types are supported:

  • numeric:
    This type of attribute represents a floating-point number.
  • nominal:
    This type of attribute represents a fixed set of nominal values.
  • string:
    This type of attribute represents a dynamically expanding set of nominal values. Usually used in text classification.
  • date:
    This type of attribute represents a date, internally represented as floating-point number storing the milliseconds since January 1, 1970, 00:00:00 GMT. The string representation of the date must be ISO-8601 compliant, the default is yyyy-MM-dd'T'HH:mm:ss.
  • relational:
    This type of attribute can contain other attributes and is, e.g., used for representing Multi-Instance data. (Multi-Instance data consists of a nominal attribute containing the bag-id, then a relational attribute with all the attributes of the bag, and finally the class attribute.)
Typical usage (code from the main() method of this class):

...
// 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);
...


author:
   Eibe Frank (eibe@cs.waikato.ac.nz)
version:
   $Revision: 1.44 $



Field Summary
final public static  StringARFF_ATTRIBUTE
    
final public static  StringARFF_ATTRIBUTE_DATE
    
final public static  StringARFF_ATTRIBUTE_INTEGER
    
final public static  StringARFF_ATTRIBUTE_NUMERIC
    
final public static  StringARFF_ATTRIBUTE_REAL
    
final public static  StringARFF_ATTRIBUTE_RELATIONAL
    
final public static  StringARFF_ATTRIBUTE_STRING
    
final public static  StringARFF_END_SUBRELATION
    
final public static  intDATE
     Constant set for attributes with date values.
final public static  intNOMINAL
     Constant set for nominal attributes.
final public static  intNUMERIC
     Constant set for numeric attributes.
final public static  intORDERING_MODULO
     Constant set for modulo-ordered attributes.
final public static  intORDERING_ORDERED
     Constant set for ordered attributes.
final public static  intORDERING_SYMBOLIC
     Constant set for symbolic attributes.
final public static  intRELATIONAL
     Constant set for relation-valued attributes.
final public static  intSTRING
     Constant set for attributes with string values.
final static  longserialVersionUID
    

Constructor Summary
public  Attribute(String attributeName)
     Constructor for a numeric attribute.
public  Attribute(String attributeName, ProtectedProperties metadata)
     Constructor for a numeric attribute, where metadata is supplied.
public  Attribute(String attributeName, String dateFormat)
     Constructor for a date attribute.
public  Attribute(String attributeName, String dateFormat, ProtectedProperties metadata)
     Constructor for a date attribute, where metadata is supplied.
public  Attribute(String attributeName, FastVector attributeValues)
     Constructor for nominal attributes and string attributes. If a null vector of attribute values is passed to the method, the attribute is assumed to be a string.
Parameters:
  attributeName - the name for the attribute
Parameters:
  attributeValues - a vector of strings denoting the attribute values.
public  Attribute(String attributeName, FastVector attributeValues, ProtectedProperties metadata)
     Constructor for nominal attributes and string attributes, where metadata is supplied.
public  Attribute(String attributeName, Instances header)
     Constructor for relation-valued attributes.
public  Attribute(String attributeName, Instances header, ProtectedProperties metadata)
     Constructor for relation-valued attributes.
public  Attribute(String attributeName, int index)
     Constructor for a numeric attribute with a particular index.
public  Attribute(String attributeName, String dateFormat, int index)
     Constructor for date attributes with a particular index.
Parameters:
  attributeName - the name for the attribute
Parameters:
  dateFormat - a string suitable for use withSimpleDateFormatter for parsing dates.
public  Attribute(String attributeName, FastVector attributeValues, int index)
     Constructor for nominal attributes and string attributes with a particular index.
public  Attribute(String attributeName, Instances header, int index)
     Constructor for a relation-valued attribute with a particular index.

Method Summary
public  intaddRelation(Instances value)
     Adds a relation to a relation-valued attribute.
public  intaddStringValue(String value)
     Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string.
public  intaddStringValue(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.
final  voidaddValue(String value)
     Adds an attribute value.
public  Objectcopy()
     Produces a shallow copy of this attribute.
final public  Attributecopy(String newName)
     Produces a shallow copy of this attribute with a new name.
final  voiddelete(int index)
     Removes a value of a nominal, string, or relation-valued attribute.
final public  EnumerationenumerateValues()
     Returns an enumeration of all the attribute's values if the attribute is nominal, string, or relation-valued, null otherwise.
final public  booleanequals(Object other)
     Tests if given attribute is equal to this attribute.
final  voidforceAddValue(String value)
     Adds an attribute value.
public  StringformatDate(double date)
     Returns the given amount of milliseconds formatted according to the current Date format.
final public  StringgetDateFormat()
     Returns the Date format pattern in case this attribute is of type DATE, otherwise an empty string.
final public  doublegetLowerNumericBound()
     Returns the lower bound of a numeric attribute.
final public  ProtectedPropertiesgetMetadata()
     Returns the properties supplied for this attribute.
final public  doublegetUpperNumericBound()
     Returns the upper bound of a numeric attribute.
final public  booleanhasZeropoint()
     Returns whether the attribute has a zeropoint and may be added meaningfully.
final public  intindex()
     Returns the index of this attribute.
final public  intindexOfValue(String value)
     Returns the index of a given attribute value.
final public  booleanisAveragable()
     Returns whether the attribute can be averaged meaningfully.
final public  booleanisDate()
     Tests if the attribute is a date type.
final public  booleanisInRange(double value)
     Determines whether a value lies within the bounds of the attribute.
final public  booleanisNominal()
     Test if the attribute is nominal.
final public  booleanisNumeric()
     Tests if the attribute is numeric.
final public  booleanisRegular()
     Returns whether the attribute values are equally spaced.
final public  booleanisRelationValued()
     Tests if the attribute is relation valued.
final public  booleanisString()
     Tests if the attribute is a string.
final public  booleanlowerNumericBoundIsOpen()
     Returns whether the lower numeric bound of the attribute is open.
public static  voidmain(String[] ops)
     Simple main method for testing this class.
final public  Stringname()
     Returns the attribute's name.
final public  intnumValues()
     Returns the number of attribute values.
final public  intordering()
     Returns the ordering of the attribute.
public  doubleparseDate(String string)
     Parses the given String as Date, according to the current format and returns the corresponding amount of milliseconds.
final public  Instancesrelation()
     Returns the header info for a relation-valued attribute, null if the attribute is not relation-valued.
final public  Instancesrelation(int valIndex)
     Returns a value of a relation-valued attribute.
final  voidsetIndex(int index)
     Sets the index of this attribute.
final  voidsetValue(int index, String string)
     Sets a value of a nominal attribute or string attribute.
final  voidsetValue(int index, Instances data)
     Sets a value of a relation-valued attribute.
public  voidsetWeight(double value)
    
final public  StringtoString()
     Returns a description of this attribute in ARFF format.
final public  inttype()
     Returns the attribute's type as an integer.
final public  booleanupperNumericBoundIsOpen()
     Returns whether the upper numeric bound of the attribute is open.
final public  Stringvalue(int valIndex)
     Returns a value of a nominal or string attribute.
final public  doubleweight()
     Returns the attribute's weight.

Field Detail
ARFF_ATTRIBUTE
final public static String ARFF_ATTRIBUTE(Code)
The keyword used to denote the start of an arff attribute declaration



ARFF_ATTRIBUTE_DATE
final public static String ARFF_ATTRIBUTE_DATE(Code)
The keyword used to denote a date attribute



ARFF_ATTRIBUTE_INTEGER
final public static String ARFF_ATTRIBUTE_INTEGER(Code)
A keyword used to denote a numeric attribute



ARFF_ATTRIBUTE_NUMERIC
final public static String ARFF_ATTRIBUTE_NUMERIC(Code)
A keyword used to denote a numeric attribute



ARFF_ATTRIBUTE_REAL
final public static String ARFF_ATTRIBUTE_REAL(Code)
A keyword used to denote a numeric attribute



ARFF_ATTRIBUTE_RELATIONAL
final public static String ARFF_ATTRIBUTE_RELATIONAL(Code)
The keyword used to denote a relation-valued attribute



ARFF_ATTRIBUTE_STRING
final public static String ARFF_ATTRIBUTE_STRING(Code)
The keyword used to denote a string attribute



ARFF_END_SUBRELATION
final public static String ARFF_END_SUBRELATION(Code)
The keyword used to denote the end of the declaration of a subrelation



DATE
final public static int DATE(Code)
Constant set for attributes with date values.



NOMINAL
final public static int NOMINAL(Code)
Constant set for nominal attributes.



NUMERIC
final public static int NUMERIC(Code)
Constant set for numeric attributes.



ORDERING_MODULO
final public static int ORDERING_MODULO(Code)
Constant set for modulo-ordered attributes.



ORDERING_ORDERED
final public static int ORDERING_ORDERED(Code)
Constant set for ordered attributes.



ORDERING_SYMBOLIC
final public static int ORDERING_SYMBOLIC(Code)
Constant set for symbolic attributes.



RELATIONAL
final public static int RELATIONAL(Code)
Constant set for relation-valued attributes.



STRING
final public static int STRING(Code)
Constant set for attributes with string values.



serialVersionUID
final static long serialVersionUID(Code)
for serialization




Constructor Detail
Attribute
public Attribute(String attributeName)(Code)
Constructor for a numeric attribute.
Parameters:
  attributeName - the name for the attribute



Attribute
public Attribute(String attributeName, ProtectedProperties metadata)(Code)
Constructor for a numeric attribute, where metadata is supplied.
Parameters:
  attributeName - the name for the attribute
Parameters:
  metadata - the attribute's properties



Attribute
public Attribute(String attributeName, String dateFormat)(Code)
Constructor for a date attribute.
Parameters:
  attributeName - the name for the attribute
Parameters:
  dateFormat - a string suitable for use withSimpleDateFormatter for parsing dates.



Attribute
public Attribute(String attributeName, String dateFormat, ProtectedProperties metadata)(Code)
Constructor for a date attribute, where metadata is supplied.
Parameters:
  attributeName - the name for the attribute
Parameters:
  dateFormat - a string suitable for use withSimpleDateFormatter for parsing dates.
Parameters:
  metadata - the attribute's properties



Attribute
public Attribute(String attributeName, FastVector attributeValues)(Code)
Constructor for nominal attributes and string attributes. If a null vector of attribute values is passed to the method, the attribute is assumed to be a string.
Parameters:
  attributeName - the name for the attribute
Parameters:
  attributeValues - a vector of strings denoting the attribute values. Null if the attribute is a string attribute.



Attribute
public Attribute(String attributeName, FastVector attributeValues, ProtectedProperties metadata)(Code)
Constructor for nominal attributes and string attributes, where metadata is supplied. If a null vector of attribute values is passed to the method, the attribute is assumed to be a string.
Parameters:
  attributeName - the name for the attribute
Parameters:
  attributeValues - a vector of strings denoting the attribute values. Null if the attribute is a string attribute.
Parameters:
  metadata - the attribute's properties



Attribute
public Attribute(String attributeName, Instances header)(Code)
Constructor for relation-valued attributes.
Parameters:
  attributeName - the name for the attribute
Parameters:
  header - an Instances object specifying the header of the relation.



Attribute
public Attribute(String attributeName, Instances header, ProtectedProperties metadata)(Code)
Constructor for relation-valued attributes.
Parameters:
  attributeName - the name for the attribute
Parameters:
  header - an Instances object specifying the header of the relation.
Parameters:
  metadata - the attribute's properties



Attribute
public Attribute(String attributeName, int index)(Code)
Constructor for a numeric attribute with a particular index.
Parameters:
  attributeName - the name for the attribute
Parameters:
  index - the attribute's index



Attribute
public Attribute(String attributeName, String dateFormat, int index)(Code)
Constructor for date attributes with a particular index.
Parameters:
  attributeName - the name for the attribute
Parameters:
  dateFormat - a string suitable for use withSimpleDateFormatter for parsing dates. Null for a default formatstring.
Parameters:
  index - the attribute's index



Attribute
public Attribute(String attributeName, FastVector attributeValues, int index)(Code)
Constructor for nominal attributes and string attributes with a particular index. If a null vector of attribute values is passed to the method, the attribute is assumed to be a string.
Parameters:
  attributeName - the name for the attribute
Parameters:
  attributeValues - a vector of strings denoting the attribute values.Null if the attribute is a string attribute.
Parameters:
  index - the attribute's index



Attribute
public Attribute(String attributeName, Instances header, int index)(Code)
Constructor for a relation-valued attribute with a particular index.
Parameters:
  attributeName - the name for the attribute
Parameters:
  header - the header information for this attribute
Parameters:
  index - the attribute's index




Method Detail
addRelation
public int addRelation(Instances value)(Code)
Adds a relation to a relation-valued attribute.
Parameters:
  value - The value to add the index assigned to the value, or -1 if the attribute is notof type Attribute.RELATIONAL



addStringValue
public int addStringValue(String value)(Code)
Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string.
Parameters:
  value - The string value to add the index assigned to the string, or -1 if the attribute is notof type Attribute.STRING



addStringValue
public int addStringValue(Attribute src, int index)(Code)
Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string. This method is more efficient than addStringValue(String) for long strings.
Parameters:
  src - The Attribute containing the string value to add.
Parameters:
  index - the index of the string value in the source attribute. the index assigned to the string, or -1 if the attribute is notof type Attribute.STRING



addValue
final void addValue(String value)(Code)
Adds an attribute value. Creates a fresh list of attribute values before adding it.
Parameters:
  value - the attribute value



copy
public Object copy()(Code)
Produces a shallow copy of this attribute. a copy of this attribute with the same index



copy
final public Attribute copy(String newName)(Code)
Produces a shallow copy of this attribute with a new name.
Parameters:
  newName - the name of the new attribute a copy of this attribute with the same index



delete
final void delete(int index)(Code)
Removes a value of a nominal, string, or relation-valued attribute. Creates a fresh list of attribute values before removing it.
Parameters:
  index - the value's index
throws:
  IllegalArgumentException - if the attribute is not of the correct type



enumerateValues
final public Enumeration enumerateValues()(Code)
Returns an enumeration of all the attribute's values if the attribute is nominal, string, or relation-valued, null otherwise. enumeration of all the attribute's values



equals
final public boolean equals(Object other)(Code)
Tests if given attribute is equal to this attribute.
Parameters:
  other - the Object to be compared to this attribute true if the given attribute is equal to this attribute



forceAddValue
final void forceAddValue(String value)(Code)
Adds an attribute value.
Parameters:
  value - the attribute value



formatDate
public String formatDate(double date)(Code)
Returns the given amount of milliseconds formatted according to the current Date format.
Parameters:
  date - the date, represented in milliseconds since January 1, 1970, 00:00:00 GMT, to return as string the formatted date



getDateFormat
final public String getDateFormat()(Code)
Returns the Date format pattern in case this attribute is of type DATE, otherwise an empty string. the date format pattern
See Also:   SimpleDateFormat



getLowerNumericBound
final public double getLowerNumericBound()(Code)
Returns the lower bound of a numeric attribute. the lower bound of the specified numeric range



getMetadata
final public ProtectedProperties getMetadata()(Code)
Returns the properties supplied for this attribute. metadata for this attribute



getUpperNumericBound
final public double getUpperNumericBound()(Code)
Returns the upper bound of a numeric attribute. the upper bound of the specified numeric range



hasZeropoint
final public boolean hasZeropoint()(Code)
Returns whether the attribute has a zeropoint and may be added meaningfully. whether the attribute has a zeropoint or not



index
final public int index()(Code)
Returns the index of this attribute. the index of this attribute



indexOfValue
final public int indexOfValue(String value)(Code)
Returns the index of a given attribute value. (The index of the first occurence of this value.)
Parameters:
  value - the value for which the index is to be returned the index of the given attribute value if attributeis nominal or a string, -1 if it is not or the value can't be found



isAveragable
final public boolean isAveragable()(Code)
Returns whether the attribute can be averaged meaningfully. whether the attribute can be averaged or not



isDate
final public boolean isDate()(Code)
Tests if the attribute is a date type. true if the attribute is a date type



isInRange
final public boolean isInRange(double value)(Code)
Determines whether a value lies within the bounds of the attribute.
Parameters:
  value - the value to check whether the value is in range



isNominal
final public boolean isNominal()(Code)
Test if the attribute is nominal. true if the attribute is nominal



isNumeric
final public boolean isNumeric()(Code)
Tests if the attribute is numeric. true if the attribute is numeric



isRegular
final public boolean isRegular()(Code)
Returns whether the attribute values are equally spaced. whether the attribute is regular or not



isRelationValued
final public boolean isRelationValued()(Code)
Tests if the attribute is relation valued. true if the attribute is relation valued



isString
final public boolean isString()(Code)
Tests if the attribute is a string. true if the attribute is a string



lowerNumericBoundIsOpen
final public boolean lowerNumericBoundIsOpen()(Code)
Returns whether the lower numeric bound of the attribute is open. whether the lower numeric bound is open or not (closed)



main
public static void main(String[] ops)(Code)
Simple main method for testing this class.
Parameters:
  ops - the commandline options



name
final public String name()(Code)
Returns the attribute's name. the attribute's name as a string



numValues
final public int numValues()(Code)
Returns the number of attribute values. Returns 0 for attributes that are not either nominal, string, or relation-valued. the number of attribute values



ordering
final public int ordering()(Code)
Returns the ordering of the attribute. One of the following: ORDERING_SYMBOLIC - attribute values should be treated as symbols. ORDERING_ORDERED - attribute values have a global ordering. ORDERING_MODULO - attribute values have an ordering which wraps. the ordering type of the attribute



parseDate
public double parseDate(String string) throws ParseException(Code)
Parses the given String as Date, according to the current format and returns the corresponding amount of milliseconds.
Parameters:
  string - the date to parse the date in milliseconds since January 1, 1970, 00:00:00 GMT
throws:
  ParseException - if parsing fails



relation
final public Instances relation()(Code)
Returns the header info for a relation-valued attribute, null if the attribute is not relation-valued. the attribute's value as an Instances object



relation
final public Instances relation(int valIndex)(Code)
Returns a value of a relation-valued attribute. Returns null if the attribute is not relation-valued.
Parameters:
  valIndex - the value's index the attribute's value as an Instances object



setIndex
final void setIndex(int index)(Code)
Sets the index of this attribute.
Parameters:
  index - the index of this attribute



setValue
final void setValue(int index, String string)(Code)
Sets a value of a nominal attribute or string attribute. Creates a fresh list of attribute values before it is set.
Parameters:
  index - the value's index
Parameters:
  string - the value
throws:
  IllegalArgumentException - if the attribute is not nominal or string.



setValue
final void setValue(int index, Instances data)(Code)
Sets a value of a relation-valued attribute. Creates a fresh list of attribute values before it is set.
Parameters:
  index - the value's index
Parameters:
  data - the value
throws:
  IllegalArgumentException - if the attribute is not relation-valued.



setWeight
public void setWeight(double value)(Code)
Sets the new attribute's weight
Parameters:
  value - the new weight



toString
final public String toString()(Code)
Returns a description of this attribute in ARFF format. Quotes strings if they contain whitespace characters, or if they are a question mark. a description of this attribute as a string



type
final public int type()(Code)
Returns the attribute's type as an integer. the attribute's type.



upperNumericBoundIsOpen
final public boolean upperNumericBoundIsOpen()(Code)
Returns whether the upper numeric bound of the attribute is open. whether the upper numeric bound is open or not (closed)



value
final public String value(int valIndex)(Code)
Returns a value of a nominal or string attribute. Returns an empty string if the attribute is neither a string nor a nominal attribute.
Parameters:
  valIndex - the value's index the attribute's value as a string



weight
final public double weight()(Code)
Returns the attribute's weight. the attribute's weight as a double



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.