📄 instances.html
字号:
<PRE>public void <B>randomize</B>(java.util.Random random)</PRE><DL><DD>Shuffles the instances in the set so that they are ordered randomly.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>random</CODE> - a random number generator</DL></DD></DL><HR><A NAME="readInstance(java.io.Reader)"><!-- --></A><H3>readInstance</H3><PRE>public boolean <B>readInstance</B>(java.io.Reader reader) throws java.io.IOException</PRE><DL><DD>Reads a single instance from the reader and appends it to the dataset. Automatically expands the dataset if it is not large enough to hold the instance. This method does not check for carriage return at the end of the line.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>reader</CODE> - the reader<DT><B>Returns:</B><DD>false if end of file has been reached<DT><B>Throws:</B><DD><CODE>java.io.IOException</CODE> - if the information is not read successfully</DL></DD></DL><HR><A NAME="relationName()"><!-- --></A><H3>relationName</H3><PRE>public java.lang.String <B>relationName</B>()</PRE><DL><DD>Returns the relation's name.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the relation's name as a string</DL></DD></DL><HR><A NAME="renameAttribute(int, java.lang.String)"><!-- --></A><H3>renameAttribute</H3><PRE>public void <B>renameAttribute</B>(int att, java.lang.String name)</PRE><DL><DD>Renames an attribute. This change only affects this dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - the attribute's index<DD><CODE>name</CODE> - the new name</DL></DD></DL><HR><A NAME="renameAttribute(weka.core.Attribute, java.lang.String)"><!-- --></A><H3>renameAttribute</H3><PRE>public void <B>renameAttribute</B>(<A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A> att, java.lang.String name)</PRE><DL><DD>Renames an attribute. This change only affects this dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - the attribute<DD><CODE>name</CODE> - the new name</DL></DD></DL><HR><A NAME="renameAttributeValue(int, int, java.lang.String)"><!-- --></A><H3>renameAttributeValue</H3><PRE>public void <B>renameAttributeValue</B>(int att, int val, java.lang.String name)</PRE><DL><DD>Renames the value of a nominal (or string) attribute value. This change only affects this dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - the attribute's index<DD><CODE>val</CODE> - the value's index<DD><CODE>name</CODE> - the new name</DL></DD></DL><HR><A NAME="renameAttributeValue(weka.core.Attribute, java.lang.String, java.lang.String)"><!-- --></A><H3>renameAttributeValue</H3><PRE>public void <B>renameAttributeValue</B>(<A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A> att, java.lang.String val, java.lang.String name)</PRE><DL><DD>Renames the value of a nominal (or string) attribute value. This change only affects this dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - the attribute<DD><CODE>val</CODE> - the value<DD><CODE>name</CODE> - the new name</DL></DD></DL><HR><A NAME="resample(java.util.Random)"><!-- --></A><H3>resample</H3><PRE>public <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> <B>resample</B>(java.util.Random random)</PRE><DL><DD>Creates a new dataset of the same size using random sampling with replacement.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>random</CODE> - a random number generator<DT><B>Returns:</B><DD>the new dataset</DL></DD></DL><HR><A NAME="resampleWithWeights(java.util.Random)"><!-- --></A><H3>resampleWithWeights</H3><PRE>public <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> <B>resampleWithWeights</B>(java.util.Random random)</PRE><DL><DD>Creates a new dataset of the same size using random sampling with replacement according to the current instance weights. The weights of the instances in the new dataset are set to one.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>random</CODE> - a random number generator<DT><B>Returns:</B><DD>the new dataset</DL></DD></DL><HR><A NAME="resampleWithWeights(java.util.Random, double[])"><!-- --></A><H3>resampleWithWeights</H3><PRE>public <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> <B>resampleWithWeights</B>(java.util.Random random, double[] weights)</PRE><DL><DD>Creates a new dataset of the same size using random sampling with replacement according to the given weight vector. The weights of the instances in the new dataset are set to one. The length of the weight vector has to be the same as the number of instances in the dataset, and all weights have to be positive.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>random</CODE> - a random number generator<DD><CODE>weights</CODE> - the weight vector<DT><B>Returns:</B><DD>the new dataset<DT><B>Throws:</B><DD><CODE>java.lang.IllegalArgumentException</CODE> - if the weights array is of the wrong length or contains negative weights.</DL></DD></DL><HR><A NAME="setClass(weka.core.Attribute)"><!-- --></A><H3>setClass</H3><PRE>public void <B>setClass</B>(<A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A> att)</PRE><DL><DD>Sets the class attribute.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - attribute to be the class</DL></DD></DL><HR><A NAME="setClassIndex(int)"><!-- --></A><H3>setClassIndex</H3><PRE>public void <B>setClassIndex</B>(int classIndex)</PRE><DL><DD>Sets the class index of the set. If the class index is negative there is assumed to be no class. (ie. it is undefined)<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>classIndex</CODE> - the new class index<DT><B>Throws:</B><DD><CODE>java.lang.IllegalArgumentException</CODE> - if the class index is too big or < 0</DL></DD></DL><HR><A NAME="setRelationName(java.lang.String)"><!-- --></A><H3>setRelationName</H3><PRE>public void <B>setRelationName</B>(java.lang.String newName)</PRE><DL><DD>Sets the relation's name.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newName</CODE> - the new relation name.</DL></DD></DL><HR><A NAME="sort(int)"><!-- --></A><H3>sort</H3><PRE>public void <B>sort</B>(int attIndex)</PRE><DL><DD>Sorts the instances based on an attribute. For numeric attributes, instances are sorted in ascending order. For nominal attributes, instances are sorted based on the attribute label ordering specified in the header. Instances with missing values for the attribute are placed at the end of the dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>attIndex</CODE> - the attribute's index</DL></DD></DL><HR><A NAME="sort(weka.core.Attribute)"><!-- --></A><H3>sort</H3><PRE>public void <B>sort</B>(<A HREF="../../weka/core/Attribute.html" title="class in weka.core">Attribute</A> att)</PRE><DL><DD>Sorts the instances based on an attribute. For numeric attributes, instances are sorted into ascending order. For nominal attributes, instances are sorted based on the attribute label ordering specified in the header. Instances with missing values for the attribute are placed at the end of the dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>att</CODE> - the attribute</DL></DD></DL><HR><A NAME="stratify(int)"><!-- --></A><H3>stratify</H3><PRE>public void <B>stratify</B>(int numFolds)</PRE><DL><DD>Stratifies a set of instances according to its class values if the class attribute is nominal (so that afterwards a stratified cross-validation can be performed).<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>numFolds</CODE> - the number of folds in the cross-validation<DT><B>Throws:</B><DD><CODE><A HREF="../../weka/core/UnassignedClassException.html" title="class in weka.core">UnassignedClassException</A></CODE> - if the class is not set</DL></DD></DL><HR><A NAME="sumOfWeights()"><!-- --></A><H3>sumOfWeights</H3><PRE>public double <B>sumOfWeights</B>()</PRE><DL><DD>Computes the sum of all the instances' weights.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the sum of all the instances' weights as a double</DL></DD></DL><HR><A NAME="testCV(int, int)"><!-- --></A><H3>testCV</H3><PRE>public <A HREF="../../weka/core/Instances.html" title="class in weka.core">Instances</A> <B>testCV</B>(int numFolds, int numFold)</PRE><DL><DD>Creates the test set for one fold of a cross-validation on the dataset.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>numFolds</CODE> - the number of folds in the cross-validation. Must be greater than 1.<DD><CODE>numFold</CODE> - 0 for the first fold, 1 for the second, ...<DT><B>Returns:</B><DD>the test set as a set of weighted instances<DT><B>Throws:</B><DD><CODE>java.lang.IllegalArgumentException</CODE> - if the number of folds is less than 2 or greater than the number of instances.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public java.lang.String <B>toString</B>()</PRE><DL><DD>Returns the dataset as a string in ARFF format. Strings are quoted if they contain whitespace characters, or if they are a question mark.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the dataset in ARFF format as a string</DL></DD></DL><HR><A NAME="trainCV(int, int)"><!-- --></A><H3>trainCV</H3><PRE>public <A HREF="../../weka/core/I
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -