weka.classifiers.trees.ht.ActiveHNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weka-dev Show documentation
Show all versions of weka-dev Show documentation
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This version represents the developer version, the
"bleeding edge" of development, you could say. New functionality gets added
to this version.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* ActiveHNode.java
* Copyright (C) 2013 University of Waikato, Hamilton, New Zealand
*
*/
package weka.classifiers.trees.ht;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weka.core.Attribute;
import weka.core.Instance;
/**
* Node that is "active" (i.e. growth can occur) in a Hoeffding tree
*
* @author Richard Kirkby ([email protected])
* @author Mark Hall (mhall{[at]}pentaho{[dot]}com)
* @version $Revision: 9705 $
*/
public class ActiveHNode extends LeafNode implements LearningNode, Serializable {
/**
* For serialization
*/
private static final long serialVersionUID = 3284585939739561683L;
/** The weight of instances seen at the last split evaluation */
public double m_weightSeenAtLastSplitEval = 0;
/** Statistics for nominal or numeric attributes conditioned on the class */
protected Map m_nodeStats = new HashMap();
@Override
public void updateNode(Instance inst) throws Exception {
super.updateDistribution(inst);
for (int i = 0; i < inst.numAttributes(); i++) {
Attribute a = inst.attribute(i);
if (i != inst.classIndex()) {
ConditionalSufficientStats stats = m_nodeStats.get(a.name());
if (stats == null) {
if (a.isNumeric()) {
stats = new GaussianConditionalSufficientStats();
} else {
stats = new NominalConditionalSufficientStats();
}
m_nodeStats.put(a.name(), stats);
}
stats
.update(inst.value(a),
inst.classAttribute().value((int) inst.classValue()),
inst.weight());
}
}
}
/**
* Returns a list of split candidates
*
* @param splitMetric the splitting metric to use
* @return a list of split candidates
*/
public List getPossibleSplits(SplitMetric splitMetric) {
List splits = new ArrayList();
// null split
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy