what will be the output of this program Random Forest [on hold]
Can you please check if this program is correct and what will be the
output for this program. What is the input that should be given for this
program. I am trying to run this program but I am getting too many errors
so please check this code.
package weka.classifiers.trees;
import weka.classifiers.Classifier;
import weka.classifiers.AbstractClassifier;
import weka.classifiers.meta.Bagging;
import weka.core.AdditionalMeasureProducer;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.Randomizable;
import weka.core.RevisionUtils;
import weka.core.TechnicalInformation;
import weka.core.TechnicalInformationHandler;
import weka.core.Utils;
import weka.core.WeightedInstancesHandler;
import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;
import java.util.Enumeration;
import java.util.Vector;
/**
<!-- globalinfo-start -->
* Class for constructing a forest of random trees.<br/>
* <br/>
* For more information see: <br/>
* <br/>
* Leo Breiman (2001). Random Forests. Machine Learning. 45(1):5-32.
* <p/>
<!-- globalinfo-end -->
*
<!-- technical-bibtex-start -->
* BibTeX:
* <pre>
* @article{Breiman2001,
* author = {Leo Breiman},
* journal = {Machine Learning},
* number = {1},
* pages = {5-32},
* title = {Random Forests},
* volume = {45},
* year = {2001}
* }
* </pre>
* <p/>
<!-- technical-bibtex-end -->
*
<!-- options-start -->
* Valid options are: <p/>
*
* <pre> -I <number of trees>
* Number of trees to build.</pre>
*
* <pre> -K <number of features>
* Number of features to consider (<1=int(logM+1)).</pre>
*
* <pre> -S
* Seed for random number generator.
* (default 1)</pre>
*
* <pre> -depth <num>
* The maximum depth of the trees, 0 for unlimited.
* (default 0)</pre>
*
* <pre> -D
* If set, classifier is run in debug mode and
* may output additional info to the console</pre>
*
<!-- options-end -->
*
* @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
* @version $Revision: 5928 $
*/
public class RandomForest
extends AbstractClassifier
implements OptionHandler, Randomizable, WeightedInstancesHandler,
AdditionalMeasureProducer, TechnicalInformationHandler {
/** for serialization */
static final long serialVersionUID = 4216839470751428698L;
/** Number of trees in forest. */
protected int m_numTrees = 10;
/** Number of features to consider in random feature selection.
If less than 1 will use int(logM+1) ) */
protected int m_numFeatures = 0;
/** The random seed. */
protected int m_randomSeed = 1;
/** Final number of features that were considered in last build. */
protected int m_KValue = 0;
/** The bagger. */
protected Bagging m_bagger = null;
/** The maximum depth of the trees (0 = unlimited) */
protected int m_MaxDepth = 0;
/**
* Returns a string describing classifier
* @return a description suitable for
* displaying in the explorer/experimenter gui
*/
public String globalInfo() {
return
"Class for constructing a forest of random trees.\n\n"
+ "For more information see: \n\n"
+ getTechnicalInformation().toString();
}
/**
* Returns an instance of a TechnicalInformation object, containing
* detailed information about the technical background of this class,
* e.g., paper reference or book this class is based on.
*
* @return the technical information about this class
*/
public TechnicalInformation getTechnicalInformation() {
TechnicalInformation result;
result = new TechnicalInformation(Type.ARTICLE);
result.setValue(Field.AUTHOR, "Leo Breiman");
result.setValue(Field.YEAR, "2001");
result.setValue(Field.TITLE, "Random Forests");
result.setValue(Field.JOURNAL, "Machine Learning");
result.setValue(Field.VOLUME, "45");
result.setValue(Field.NUMBER, "1");
result.setValue(Field.PAGES, "5-32");
return result;
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String numTreesTipText() {
return "The number of trees to be generated.";
}
/**
* Get the value of numTrees.
*
* @return Value of numTrees.
*/
public int getNumTrees() {
return m_numTrees;
}
/**
* Set the value of numTrees.
*
* @param newNumTrees Value to assign to numTrees.
*/
public void setNumTrees(int newNumTrees) {
m_numTrees = newNumTrees;
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String numFeaturesTipText() {
return "The number of attributes to be used in random selection (see
RandomTree).";
}
/**
* Get the number of features used in random selection.
*
* @return Value of numFeatures.
*/
public int getNumFeatures() {
return m_numFeatures;
}
/**
* Set the number of features to use in random selection.
*
* @param newNumFeatures Value to assign to numFeatures.
*/
public void setNumFeatures(int newNumFeatures) {
m_numFeatures = newNumFeatures;
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String seedTipText() {
return "The random number seed to be used.";
}
/**
* Set the seed for random number generation.
*
* @param seed the seed
*/
public void setSeed(int seed) {
m_randomSeed = seed;
}
/**
* Gets the seed for the random number generations
*
* @return the seed for the random number generation
*/
public int getSeed() {
return m_randomSeed;
}
/**
* Returns the tip text for this property
*
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String maxDepthTipText() {
return "The maximum depth of the trees, 0 for unlimited.";
}
/**
* Get the maximum depth of trh tree, 0 for unlimited.
*
* @return the maximum depth.
*/
public int getMaxDepth() {
return m_MaxDepth;
}
/**
* Set the maximum depth of the tree, 0 for unlimited.
*
* @param value the maximum depth.
*/
public void setMaxDepth(int value) {
m_MaxDepth = value;
}
/**
* Gets the out of bag error that was calculated as the classifier was
built.
*
* @return the out of bag error
*/
public double measureOutOfBagError() {
if (m_bagger != null) {
return m_bagger.measureOutOfBagError();
} else return Double.NaN;
}
/**
* Returns an enumeration of the additional measure names.
*
* @return an enumeration of the measure names
*/
public Enumeration enumerateMeasures() {
Vector newVector = new Vector(1);
newVector.addElement("measureOutOfBagError");
return newVector.elements();
}
/**
* Returns the value of
No comments:
Post a Comment