Example usage for weka.classifiers.functions LinearRegression setAttributeSelectionMethod

List of usage examples for weka.classifiers.functions LinearRegression setAttributeSelectionMethod

Introduction

In this page you can find the example usage for weka.classifiers.functions LinearRegression setAttributeSelectionMethod.

Prototype

public void setAttributeSelectionMethod(SelectedTag method) 

Source Link

Document

Sets the method used to select attributes for use in the linear regression.

Usage

From source file:edu.utexas.cs.tactex.utils.RegressionUtils.java

License:Open Source License

public static LinearRegression createLinearRegression() {
    LinearRegression linreg = new LinearRegression();
    linreg.setAttributeSelectionMethod(
            new SelectedTag(LinearRegression.SELECTION_NONE, LinearRegression.TAGS_SELECTION));
    linreg.setEliminateColinearAttributes(false);
    // if wants debug info
    //linreg.setDebug(true);
    return linreg;
}

From source file:jjj.asap.sas.models1.job.BuildRegressionModels.java

License:Open Source License

@Override
protected void run() throws Exception {

    // validate args
    if (!Bucket.isBucket("datasets", inputBucket)) {
        throw new FileNotFoundException(inputBucket);
    }//  w  w w.j a v a2s.c om
    if (!Bucket.isBucket("models", outputBucket)) {
        throw new FileNotFoundException(outputBucket);
    }

    // create prototype classifiers
    List<Classifier> models = new ArrayList<Classifier>();

    LinearRegression m5 = new LinearRegression();
    m5.setAttributeSelectionMethod(M5);

    LinearRegression lr = new LinearRegression();
    lr.setAttributeSelectionMethod(NONE);

    RandomSubSpace rss = new RandomSubSpace();
    rss.setClassifier(lr);
    rss.setNumIterations(30);

    AdditiveRegression boostedStumps = new AdditiveRegression();
    boostedStumps.setClassifier(new DecisionStump());
    boostedStumps.setNumIterations(1000);

    AdditiveRegression boostedTrees = new AdditiveRegression();
    boostedTrees.setClassifier(new REPTree());
    boostedTrees.setNumIterations(100);

    models.add(m5);
    models.add(boostedStumps);
    models.add(boostedTrees);
    models.add(rss);

    // init multi-threading
    Job.startService();
    final Queue<Future<Object>> queue = new LinkedList<Future<Object>>();

    // get the input from the bucket
    List<String> names = Bucket.getBucketItems("datasets", this.inputBucket);
    for (String dsn : names) {

        for (Classifier model : models) {

            String tag = null;
            if (model instanceof SingleClassifierEnhancer) {
                tag = model.getClass().getSimpleName() + "-"
                        + ((SingleClassifierEnhancer) model).getClassifier().getClass().getSimpleName();
            } else {
                tag = model.getClass().getSimpleName();
            }

            queue.add(Job.submit(new RegressionModelBuilder(dsn, tag, AbstractClassifier.makeCopy(model),
                    this.outputBucket)));
        }
    }

    // wait on complete
    Progress progress = new Progress(queue.size(), this.getClass().getSimpleName());
    while (!queue.isEmpty()) {
        try {
            queue.remove().get();
        } catch (Exception e) {
            Job.log("ERROR", e.toString());
        }
        progress.tick();
    }
    progress.done();
    Job.stopService();

}

From source file:jjj.asap.sas.models1.job.RGramModels.java

License:Open Source License

@Override
protected void run() throws Exception {

    // validate args
    if (!Bucket.isBucket("datasets", inputBucket)) {
        throw new FileNotFoundException(inputBucket);
    }/* w  ww .j  a  va2 s  . c  o  m*/
    if (!Bucket.isBucket("models", outputBucket)) {
        throw new FileNotFoundException(outputBucket);
    }

    // create prototype classifiers
    List<Classifier> models = new ArrayList<Classifier>();

    //SGD sgd = new SGD();
    //sgd.setDontNormalize(true);
    //sgd.setLossFunction(new SelectedTag(SGD.SQUAREDLOSS,SGD.TAGS_SELECTION));

    LinearRegression m5 = new LinearRegression();
    m5.setAttributeSelectionMethod(M5);

    //models.add(sgd);
    models.add(m5);

    LinearRegression lr = new LinearRegression();
    lr.setAttributeSelectionMethod(NONE);

    RandomSubSpace rss = new RandomSubSpace();
    rss.setClassifier(lr);
    rss.setNumIterations(30);

    models.add(rss);

    AdditiveRegression boostedStumps = new AdditiveRegression();
    boostedStumps.setClassifier(new DecisionStump());
    boostedStumps.setNumIterations(1000);

    AdditiveRegression boostedTrees = new AdditiveRegression();
    boostedTrees.setClassifier(new REPTree());
    boostedTrees.setNumIterations(100);

    models.add(boostedStumps);
    models.add(boostedTrees);

    models.add(new PLSClassifier());

    // init multi-threading
    Job.startService();
    final Queue<Future<Object>> queue = new LinkedList<Future<Object>>();

    // get the input from the bucket
    List<String> names = Bucket.getBucketItems("datasets", this.inputBucket);
    for (String dsn : names) {

        for (Classifier model : models) {

            String tag = null;
            if (model instanceof SingleClassifierEnhancer) {
                tag = model.getClass().getSimpleName() + "-"
                        + ((SingleClassifierEnhancer) model).getClassifier().getClass().getSimpleName();
            } else {
                tag = model.getClass().getSimpleName();
            }

            queue.add(Job.submit(new RegressionModelBuilder(dsn, tag, AbstractClassifier.makeCopy(model),
                    this.outputBucket)));
        }
    }

    // wait on complete
    Progress progress = new Progress(queue.size(), this.getClass().getSimpleName());
    while (!queue.isEmpty()) {
        try {
            queue.remove().get();
        } catch (Exception e) {
            Job.log("ERROR", e.toString());
        }
        progress.tick();
    }
    progress.done();
    Job.stopService();

}