Example usage for weka.filters.unsupervised.instance RemovePercentage setOptions

List of usage examples for weka.filters.unsupervised.instance RemovePercentage setOptions

Introduction

In this page you can find the example usage for weka.filters.unsupervised.instance RemovePercentage setOptions.

Prototype

@Override
public void setOptions(String[] options) throws Exception 

Source Link

Document

Parses a given list of options.

Usage

From source file:experimentalclassifier.ExperimentalClassifier.java

/**
 * @param args the command line arguments
 *//*from   w  w w.  j  a va 2s .c o m*/
public static void main(String[] args) throws Exception {

    DataSource source = new DataSource("data/iris.csv");

    Instances data = source.getDataSet();

    if (data.classIndex() == -1) {
        data.setClassIndex(data.numAttributes() - 1);
    }

    data.randomize(new Random());

    String[] options = weka.core.Utils.splitOptions("-P 30");
    RemovePercentage remove = new RemovePercentage();
    remove.setOptions(options);
    remove.setInputFormat(data);
    Instances train = Filter.useFilter(data, remove);

    remove.setInvertSelection(true);
    remove.setInputFormat(data);
    Instances test = Filter.useFilter(data, remove);

    Classifier classifier = new HardCodedClassifier();
    classifier.buildClassifier(train);//Currently, this does nothing
    Evaluation eval = new Evaluation(train);
    eval.evaluateModel(classifier, test);
    System.out.println(eval.toSummaryString("\nResults\n======\n", false));
}