本文整理汇总了Java中moa.classifiers.trees.HoeffdingTree类的典型用法代码示例。如果您正苦于以下问题:Java HoeffdingTree类的具体用法?Java HoeffdingTree怎么用?Java HoeffdingTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HoeffdingTree类属于moa.classifiers.trees包,在下文中一共展示了HoeffdingTree类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
public void run(int numInstances, boolean isTesting){
Classifier learner = new HoeffdingTree();
RandomRBFGenerator stream = new RandomRBFGenerator();
stream.prepareForUse();
learner.setModelContext(stream.getHeader());
learner.prepareForUse();
int numberSamplesCorrect = 0;
int numberSamples = 0;
long evaluateStartTime = TimingUtils.getNanoCPUTimeOfCurrentThread();
while (stream.hasMoreInstances() && numberSamples < numInstances) {
Instance trainInst = stream.nextInstance().getData();
if (isTesting) {
if (learner.correctlyClassifies(trainInst)){
numberSamplesCorrect++;
}
}
numberSamples++;
learner.trainOnInstance(trainInst);
}
double accuracy = 100.0 * (double) numberSamplesCorrect/ (double) numberSamples;
double time = TimingUtils.nanoTimeToSeconds(TimingUtils.getNanoCPUTimeOfCurrentThread()- evaluateStartTime);
System.out.println(numberSamples + " instances processed with " + accuracy + "% accuracy in "+time+" seconds.");
}
示例2: createAndShowGUI
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
private static void createAndShowGUI() {
// Create and set up the window.
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and set up the content pane.
Options options = new HoeffdingTree().getOptions();
JPanel panel = new OptionsConfigurationPanel(null, options);
// createLabelledOptionComponentListPanel(options
// .getOptionArray(), null);
panel.setOpaque(true); // content panes must be opaque
frame.setContentPane(panel);
// Display the window.
frame.pack();
// frame.setSize(400, 400);
frame.setVisible(true);
}
示例3: enforceMemoryLimit
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
/**
* Checks if the memory limit is exceeded and if so prunes the classifiers in the ensemble.
*/
protected void enforceMemoryLimit() {
double memoryLimit = this.maxByteSizeOption.getValue() / (double) (this.learners.length + 1);
for (int i = 0; i < this.learners.length; i++) {
((HoeffdingTree) this.learners[(int) this.weights[i][1]]).maxByteSizeOption.setValue((int) Math
.round(memoryLimit));
((HoeffdingTree) this.learners[(int) this.weights[i][1]]).enforceTrackerLimit();
}
}
示例4: enforceMemoryLimit
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
/**
* Checks if the memory limit is exceeded and if so prunes the classifiers in the ensemble.
*/
protected void enforceMemoryLimit() {
double memoryLimit = this.maxByteSizeOption.getValue() / (double) (this.ensemble.length + 1);
for (int i = 0; i < this.ensemble.length; i++) {
((HoeffdingTree) this.ensemble[(int) this.weights[i][1]].classifier).maxByteSizeOption.setValue((int) Math
.round(memoryLimit));
((HoeffdingTree) this.ensemble[(int) this.weights[i][1]].classifier).enforceTrackerLimit();
}
}
示例5: getClassVotes
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public double[] getClassVotes(Instance inst, HoeffdingTree ht) {
if (getWeightSeen() >= ((HoeffdingTreeClassifLeaves) ht).nbThresholdOption.getValue()) {
return this.classifier.getVotesForInstance(inst);
}
return super.getClassVotes(inst, ht);
}
示例6: getClassVotes
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public double[] getClassVotes(Instance inst, HoeffdingTree ht) {
if (getWeightSeen() >= ((HoeffdingAdaptiveTreeClassifLeaves) ht).nbThresholdOption.getValue()) {
return this.classifier.getVotesForInstance(inst);
}
return super.getClassVotes(inst, ht);
}
示例7: learnFromInstance
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public void learnFromInstance(Instance inst, HoeffdingTree ht) {
List<Integer> labels = ((MultilabelHoeffdingTree) ht).getRelevantLabels(inst);
for (int l : labels){
this.observedClassDistribution.addToValue( l, inst.weight());
}
}
示例8: describeSubtree
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
public void describeSubtree(HoeffdingTree ht, StringBuilder out,
int indent) {
StringUtils.appendIndented(out, indent, "Leaf ");
out.append(" = ");
out.append(" weights: ");
this.observedClassDistribution.getSingleLineDescription(out,
this.observedClassDistribution.numValues());
StringUtils.appendNewline(out);
}
示例9: learnFromInstance
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public void learnFromInstance(Instance inst, HoeffdingTree ht) {
this.classifier.trainOnInstance(inst);
super.learnFromInstance(inst, ht);
}
示例10: learnFromInstance
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public void learnFromInstance(Instance inst, HoeffdingTree ht) {
learnFromInstance(inst);
}
示例11: getClassVotes
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
@Override
public double[] getClassVotes(Instance inst, HoeffdingTree ht) {
return this.classifier.getVotesForInstance(inst);
}
示例12: getPredictionForInstance
import moa.classifiers.trees.HoeffdingTree; //导入依赖的package包/类
public Prediction getPredictionForInstance(Instance inst, HoeffdingTree ht) {
return this.classifier.getPredictionForInstance(inst);
}