Example usage for weka.filters.supervised.attribute PLSFilter setPreprocessing

List of usage examples for weka.filters.supervised.attribute PLSFilter setPreprocessing

Introduction

In this page you can find the example usage for weka.filters.supervised.attribute PLSFilter setPreprocessing.

Prototype

public void setPreprocessing(SelectedTag value) 

Source Link

Document

Sets the type of preprocessing to use

Usage

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

License:Open Source License

@Override
protected void run() throws Exception {

    // validate args
    if (!Bucket.isBucket("datasets", inputBucket)) {
        throw new FileNotFoundException(inputBucket);
    }//from  www . j a  v  a  2s .co  m
    if (!Bucket.isBucket("models", outputBucket)) {
        throw new FileNotFoundException(outputBucket);
    }

    // Standard PLS

    PLSClassifier pls = new PLSClassifier();
    PLSFilter filter = (PLSFilter) pls.getFilter();
    filter.setNumComponents(5);
    filter.setPreprocessing(NONE);

    // centered PLS

    PLSClassifier plsc = new PLSClassifier();
    PLSFilter center = (PLSFilter) plsc.getFilter();
    center.setNumComponents(5);
    center.setPreprocessing(CENTER);

    // standardized PLS

    PLSClassifier plss = new PLSClassifier();
    PLSFilter std = (PLSFilter) plss.getFilter();
    std.setNumComponents(10);
    std.setPreprocessing(STANDARDIZE);

    // 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) {

        int essaySet = Contest.getEssaySet(dsn);

        Classifier alg = pls;

        if (essaySet == 10 || dsn.contains("1grams-thru-3grams")) {
            alg = plsc;
        }

        if (essaySet == 7) {
            alg = plss;
        }

        queue.add(Job.submit(
                new RegressionModelBuilder(dsn, "PLS", AbstractClassifier.makeCopy(alg), 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();

}