use of weka.classifiers.trees.j48.Distribution in project umple by umple.
the class ClassifierDecList method buildDecList.
/**
* Builds the partial tree without hold out set.
*
* @exception Exception if something goes wrong
*/
public void buildDecList(Instances data, boolean leaf) throws Exception {
Instances[] localInstances;
int ind;
int i, j;
double sumOfWeights;
NoSplit noSplit;
m_train = null;
m_test = null;
m_isLeaf = false;
m_isEmpty = false;
m_sons = null;
indeX = 0;
sumOfWeights = data.sumOfWeights();
noSplit = new NoSplit(new Distribution(data));
if (leaf) {
m_localModel = noSplit;
} else {
m_localModel = m_toSelectModel.selectModel(data);
}
if (m_localModel.numSubsets() > 1) {
localInstances = m_localModel.split(data);
data = null;
m_sons = new ClassifierDecList[m_localModel.numSubsets()];
i = 0;
do {
i++;
ind = chooseIndex();
if (ind == -1) {
for (j = 0; j < m_sons.length; j++) {
if (m_sons[j] == null) {
m_sons[j] = getNewDecList(localInstances[j], true);
}
}
if (i < 2) {
m_localModel = noSplit;
m_isLeaf = true;
m_sons = null;
if (Utils.eq(sumOfWeights, 0)) {
m_isEmpty = true;
}
return;
}
ind = 0;
break;
} else {
m_sons[ind] = getNewDecList(localInstances[ind], false);
}
} while ((i < m_sons.length) && (m_sons[ind].m_isLeaf));
// Choose rule
indeX = chooseLastIndex();
} else {
m_isLeaf = true;
if (Utils.eq(sumOfWeights, 0)) {
m_isEmpty = true;
}
}
}
use of weka.classifiers.trees.j48.Distribution in project umple by umple.
the class ResidualSplit method buildClassifier.
/**
* Builds the split.
* Needs the Z/W values of LogitBoost for the set of instances.
*/
public void buildClassifier(Instances data, double[][] dataZs, double[][] dataWs) throws Exception {
m_numClasses = data.numClasses();
m_numInstances = data.numInstances();
if (m_numInstances == 0)
throw new Exception("Can't build split on 0 instances");
// save data/Zs/Ws
m_data = data;
m_dataZs = dataZs;
m_dataWs = dataWs;
m_attribute = data.attribute(m_attIndex);
// determine number of subsets and split point for numeric attributes
if (m_attribute.isNominal()) {
m_splitPoint = 0.0;
m_numSubsets = m_attribute.numValues();
} else {
getSplitPoint();
m_numSubsets = 2;
}
// create distribution for data
m_distribution = new Distribution(data, this);
}
Aggregations