📄 attribute.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_10) on Fri Jan 26 16:34:48 NZDT 2007 --><TITLE>Attribute</TITLE><META NAME="keywords" CONTENT="weka.core.Attribute class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="Attribute";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="http://www.cs.waikato.ac.nz/ml/weka/" target="_blank"><FONT CLASS="NavBarFont1"><B>Weka's home</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../weka/core/AllJavadoc.html" title="class in weka.core"><B>PREV CLASS</B></A> <A HREF="../../weka/core/AttributeExpression.html" title="class in weka.core"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html?weka/core/Attribute.html" target="_top"><B>FRAMES</B></A> <A HREF="Attribute.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">weka.core</FONT><BR>Class Attribute</H2><PRE>java.lang.Object <IMG SRC="../../resources/inherit.gif" ALT="extended by "><B>weka.core.Attribute</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable, <A HREF="../../weka/core/Copyable.html" title="interface in weka.core">Copyable</A></DD></DL><HR><DL><DT><PRE>public class <B>Attribute</B><DT>extends java.lang.Object<DT>implements <A HREF="../../weka/core/Copyable.html" title="interface in weka.core">Copyable</A>, java.io.Serializable</DL></PRE><P>Class for handling an attribute. Once an attribute has been created, it can't be changed. <p> The following attribute types are supported: <ul> <li> numeric: <br/> This type of attribute represents a floating-point number. </li> <li> nominal: <br/> This type of attribute represents a fixed set of nominal values. </li> <li> string: <br/> This type of attribute represents a dynamically expanding set of nominal values. Usually used in text classification. </li> <li> date: <br/> 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 <a href="http://www.iso.org/iso/en/prods-services/popstds/datesandtime.html" target="_blank"> ISO-8601</a> compliant, the default is <code>yyyy-MM-dd'T'HH:mm:ss</code>. </li> <li> relational: <br/> 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.) </li> </ul> Typical usage (code from the main() method of this class): <p> <code> ... <br> // Create numeric attributes "length" and "weight" <br> Attribute length = new Attribute("length"); <br> Attribute weight = new Attribute("weight"); <br><br> // Create vector to hold nominal values "first", "second", "third" <br> FastVector my_nominal_values = new FastVector(3); <br> my_nominal_values.addElement("first"); <br> my_nominal_values.addElement("second"); <br> my_nominal_values.addElement("third"); <br><br> // Create nominal attribute "position" <br> Attribute position = new Attribute("position", my_nominal_values);<br> ... <br> </code><p><P><P><DL><DT><B>Version:</B></DT> <DD>$Revision: 1.42 $</DD><DT><B>Author:</B></DT> <DD>Eibe Frank (eibe@cs.waikato.ac.nz)</DD><DT><B>See Also:</B><DD><A HREF="../../serialized-form.html#weka.core.Attribute">Serialized Form</A></DL><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Field Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#DATE">DATE</A></B></CODE><BR> Constant set for attributes with date values.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#NOMINAL">NOMINAL</A></B></CODE><BR> Constant set for nominal attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#NUMERIC">NUMERIC</A></B></CODE><BR> Constant set for numeric attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#ORDERING_MODULO">ORDERING_MODULO</A></B></CODE><BR> Constant set for modulo-ordered attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#ORDERING_ORDERED">ORDERING_ORDERED</A></B></CODE><BR> Constant set for ordered attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#ORDERING_SYMBOLIC">ORDERING_SYMBOLIC</A></B></CODE><BR> Constant set for symbolic attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#RELATIONAL">RELATIONAL</A></B></CODE><BR> Constant set for relation-valued attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#STRING">STRING</A></B></CODE><BR> Constant set for attributes with string values.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String)">Attribute</A></B>(java.lang.String attributeName)</CODE><BR> Constructor for a numeric attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.FastVector)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/FastVector.html" title="class in weka.core">FastVector</A> attributeValues)</CODE><BR> Constructor for nominal attributes and string attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.FastVector, weka.core.ProtectedProperties)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/FastVector.html" title="class in weka.core">FastVector</A> attributeValues, <A HREF="../../weka/core/ProtectedProperties.html" title="class in weka.core">ProtectedProperties</A> metadata)</CODE><BR> Constructor for nominal attributes and string attributes, where metadata is supplied.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.Instances)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> header)</CODE><BR> Constructor for relation-valued attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.Instances, int)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> header, int index)</CODE><BR> Constructor for a relation-valued attribute with a particular index.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.Instances, weka.core.ProtectedProperties)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> header, <A HREF="../../weka/core/ProtectedProperties.html" title="class in weka.core">ProtectedProperties</A> metadata)</CODE><BR> Constructor for relation-valued attributes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, weka.core.ProtectedProperties)">Attribute</A></B>(java.lang.String attributeName, <A HREF="../../weka/core/ProtectedProperties.html" title="class in weka.core">ProtectedProperties</A> metadata)</CODE><BR> Constructor for a numeric attribute, where metadata is supplied.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, java.lang.String)">Attribute</A></B>(java.lang.String attributeName, java.lang.String dateFormat)</CODE><BR> Constructor for a date attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Attribute.html#Attribute(java.lang.String, java.lang.String, weka.core.ProtectedProperties)">Attribute</A></B>(java.lang.String attributeName, java.lang.String dateFormat, <A HREF="../../weka/core/ProtectedProperties.html" title="class in weka.core">ProtectedProperties</A> metadata)</CODE><BR> Constructor for a date attribute, where metadata is supplied.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#addRelation(weka.core.Instances)">addRelation</A></B>(<A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> value)</CODE><BR> Adds a relation to a relation-valued attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#addStringValue(weka.core.Attribute, int)">addStringValue</A></B>(<A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A> src, int index)</CODE><BR> Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#addStringValue(java.lang.String)">addStringValue</A></B>(java.lang.String value)</CODE><BR> Adds a string value to the list of valid strings for attributes of type STRING and returns the index of the string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#copy()">copy</A></B>()</CODE><BR> Produces a shallow copy of this attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#copy(java.lang.String)">copy</A></B>(java.lang.String newName)</CODE><BR> Produces a shallow copy of this attribute with a new name.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#enumerateValues()">enumerateValues</A></B>()</CODE><BR> Returns an enumeration of all the attribute's values if the attribute is nominal, string, or relation-valued, null otherwise.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#equals(java.lang.Object)">equals</A></B>(java.lang.Object other)</CODE><BR> Tests if given attribute is equal to this attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#formatDate(double)">formatDate</A></B>(double date)</CODE><BR> Returns the given amount of milliseconds formatted according to the current Date format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#getDateFormat()">getDateFormat</A></B>()</CODE><BR> Returns the Date format pattern in case this attribute is of type DATE, otherwise an empty string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -