Example usage for weka.classifiers.meta Stacking Stacking

List of usage examples for weka.classifiers.meta Stacking Stacking

Introduction

In this page you can find the example usage for weka.classifiers.meta Stacking Stacking.

Prototype

Stacking

Source Link

Usage

From source file:com.reactivetechnologies.platform.analytics.core.IncrementalClassifierBean.java

License:Open Source License

@Override
public RegressionModel ensembleModels(List<RegressionModel> models) {
    Stacking blend = new Stacking();
    //blend.setMetaClassifier(classifier);
    Classifier[] classifiers = new Classifier[models.size()];
    int i = 0;//from   ww  w .j a  va 2s  .com
    for (RegressionModel model : models) {
        classifiers[i++] = model.getTrainedClassifier();
    }
    blend.setClassifiers(classifiers);
    RegressionModel m = new RegressionModel();
    m.setTrainedClassifier(blend);
    return m;
}

From source file:de.uniheidelberg.cl.swp.mlprocess.WEKARunner.java

License:Apache License

/**
 * Internal construction of the stacking classifier and its level 1 and level 0 algorithms.
 * //from  w  w w  .java 2  s.c  om
 * @param type A meta machine learning algorithm for level 1.
 * @param subtypes Multiple machine learning algorithms for level 0.
 * @param options Options for the classifiers.
 * @return The stacking classifier.
 */
private Stacking createStack(String type, String[] subtypes, String options) throws Exception {
    StringBuffer sb = new StringBuffer();
    Stacking stack = new Stacking();

    sb.append("-M " + getClass(Type.valueOf(type.toUpperCase())));

    for (String s : subtypes) {
        sb.append(" -B " + getClass(Type.valueOf(s.toUpperCase())));
    }
    sb.append(" " + options);

    Logging.getInstance().getLogger()
            .info("Building " + subtypes.length + " subclassifiers... this might take some time");
    stack.setOptions(Utils.splitOptions(sb.toString()));
    stack.buildClassifier(train);

    return stack;
}

From source file:meddle.TrainModelByDomainOS.java

License:Open Source License

/**
 * Given the classifierName, return a classifier
 *
 * @param classifierName//from  w w  w.  ja  v  a2  s .  co  m
 *            e.g. J48, Bagging etc.
 */
public static Classifier getClassifier(String classifierName) {
    Classifier classifier = null;
    if (classifierName.equals("J48")) {
        J48 j48 = new J48();
        j48.setUnpruned(true);
        classifier = j48;
    } else if (classifierName.equals("AdaBoostM1")) {
        AdaBoostM1 adm = new AdaBoostM1();
        adm.setNumIterations(10);
        J48 j48 = new J48();
        adm.setClassifier(j48);
        classifier = adm;
    } else if (classifierName.equals("Bagging")) {
        Bagging bagging = new Bagging();
        bagging.setNumIterations(10);
        J48 j48 = new J48();
        bagging.setClassifier(j48);
        classifier = bagging;
    } else if (classifierName.equals("Stacking")) {
        Stacking stacking = new Stacking();
        stacking.setMetaClassifier(new Logistic());
        Classifier cc[] = new Classifier[2];
        cc[0] = new J48();
        cc[1] = new IBk();
        stacking.setClassifiers(cc);
        classifier = stacking;
    } else if (classifierName.equals("AdditiveRegression")) {
        AdditiveRegression ar = new AdditiveRegression();
        ar.setClassifier(new J48());
        classifier = ar;
    } else if (classifierName.equals("LogitBoost")) {
        LogitBoost lb = new LogitBoost();
        lb.setClassifier(new J48());
        classifier = lb;
    }
    return classifier;
}