本文整理匯總了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);
}