Example usage for weka.classifiers.trees.m5 RuleNode splitAtt

List of usage examples for weka.classifiers.trees.m5 RuleNode splitAtt

Introduction

In this page you can find the example usage for weka.classifiers.trees.m5 RuleNode splitAtt.

Prototype

public int splitAtt() 

Source Link

Document

Get the index of the splitting attribute for this node

Usage

From source file:cn.ict.zyq.bestConf.COMT2.COMT2.java

License:Open Source License

private ArrayList<Branch2> getLeavesInfoForM5P(M5P model) {
    ArrayList<Branch2> retval = new ArrayList<Branch2>();
    ArrayList<RuleNode> leafNodes = new ArrayList<RuleNode>();
    model.getM5RootNode().returnLeaves(new ArrayList[] { leafNodes });

    for (RuleNode leaf : leafNodes) {
        Branch2 branch = new Branch2();
        ArrayList<PreConstructedLinearModel> lmodel = new ArrayList<PreConstructedLinearModel>();
        lmodel.add(leaf.getModel());//  w ww .  j  a v  a 2 s. com
        branch.setLinearModels(lmodel);

        Map<Attribute, Range<Double>> rangeMap = branch.getRangeMap();
        RuleNode parent = leaf, child;
        while (parent.parentNode() != null) {
            child = parent;
            parent = parent.parentNode();

            Attribute att = this.labeledInstances.attribute(parent.splitAtt());
            Range<Double> previous = null;
            if (parent.leftNode() == child)
                previous = rangeMap.put(att, Range.atMost(parent.splitVal()));
            else
                previous = rangeMap.put(att, Range.greaterThan(parent.splitVal()));
            //the attribute is visited previously
            if (previous != null) {
                previous = rangeMap.get(att).intersection(previous);
                rangeMap.put(att, previous);
            }
        }

        retval.add(branch);
    }

    return retval;
}

From source file:cn.ict.zyq.bestConf.COMT2.COMT2.java

License:Open Source License

private static Instances getSiblings(M5P modelTree, Instance ins) {
    RuleNode node = modelTree.getM5RootNode();

    while (!node.isLeaf()) {
        if (ins.value(node.splitAtt()) <= node.splitVal()) {
            node = node.leftNode();//from  ww  w  . j a v a  2  s  . co  m
        } else {
            node = node.rightNode();
        }
    }

    return node.zyqGetTrainingSet();
}