📄 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.4.2_05) on Mon Mar 07 15:27:45 NZDT 2005 --><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></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=3 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="../../../Tutorial.pdf"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="http://www.cs.waikato.ac.nz/ml/weka/index.html"><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"> PREV CLASS <A HREF="../../weka/core/AttributeStats.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" 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><A HREF="../../weka/core/Copyable.html" title="interface in weka.core">Copyable</A>, java.io.Serializable</DD></DL><HR><DL><DT>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><P>Class for handling an attribute. Once an attribute has been created, it can't be changed. <p> Three attribute types are supported: <ul> <li> numeric: <ul> This type of attribute represents a floating-point number. </ul> <li> nominal: <ul> This type of attribute represents a fixed set of nominal values. </ul> <li> string: <ul> This type of attribute represents a dynamically expanding set of nominal values. String attributes are not used by the learning schemes in Weka. They can be used, for example, to store an identifier with each instance in a dataset. </ul> </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.32.2.1 $</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><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></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#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#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"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></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.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"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></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> 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 or a string, 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> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#getLowerNumericBound()">getLowerNumericBound</A></B>()</CODE><BR> Returns the lower bound of a numeric attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../weka/core/ProtectedProperties.html" title="class in weka.core">ProtectedProperties</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#getMetadata()">getMetadata</A></B>()</CODE><BR> Returns the properties supplied for this attribute.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Attribute.html#getUpperNumericBound()">getUpperNumericBound</A></B>()</CODE><BR> Returns the upper bound of a numeric attribute.</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#hasZeropoint()">hasZeropoint</A></B>()</CODE><BR> Returns whether the attribute has a zeropoint and may be added meaningfully.</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#index()">index</A></B>()</CODE><BR> Returns the index of this 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#indexOfValue(java.lang.String)">indexOfValue</A></B>(java.lang.String value)</CODE><BR> Returns the index of a given attribute value.</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#isAveragable()">isAveragable</A></B>()</CODE><BR> Returns whether the attribute can be averaged meaningfully.</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#isDate()">isDate</A></B>()</CODE><BR> Tests if the attribute is a date type.</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#isInRange(double)">isInRange</A></B>(double value)</CODE><BR> Determines whether a value lies within the bounds of the attribute.</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#isNominal()">isNominal</A></B>()</CODE><BR> Test if the attribute is nominal.</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#isNumeric()">isNumeric</A></B>()</CODE><BR> Tests if the attribute is numeric.</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#isRegular()">isRegular</A></B>()</CODE><BR> Returns whether the attribute values are equally spaced.</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#isString()">isString</A></B>()</CODE><BR> Tests if the attribute is a string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -