Search in sources :

Example 6 with NoSplit

use of weka.classifiers.trees.j48.NoSplit 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;
        }
    }
}
Also used : Instances(weka.core.Instances) Distribution(weka.classifiers.trees.j48.Distribution) NoSplit(weka.classifiers.trees.j48.NoSplit)

Aggregations

NoSplit (weka.classifiers.trees.j48.NoSplit)6 Distribution (weka.classifiers.trees.j48.Distribution)4 Instances (weka.core.Instances)3