Example usage for weka.core.converters LibSVMLoader getDataSet

List of usage examples for weka.core.converters LibSVMLoader getDataSet

Introduction

In this page you can find the example usage for weka.core.converters LibSVMLoader getDataSet.

Prototype

@Override
public Instances getDataSet() throws IOException 

Source Link

Document

Return the full data set.

Usage

From source file:cish.CISH.java

private void trainClassifier() {
    try {/*from w  ww .j a v a2 s  . co  m*/
        LibSVMLoader loader = new LibSVMLoader();
        loader.setSource(getClass().getResource("/cish/traindata.libsvm"));
        Instances traindata = loader.getDataSet();

        // Set the class attribute as nominal
        NumericToNominal filter = new NumericToNominal();
        filter.setAttributeIndices("last");
        filter.setInputFormat(traindata);
        dataset = Filter.useFilter(traindata, filter);

        // Train the LibSVM
        classifier = new LibSVM();
        classifier.setOptions(new String[] { "-C", "8", "-G", "0.0625" });

        System.out.println("CISH classifier has options");
        for (String o : classifier.getOptions()) {
            System.out.print(o + " ");
        }
        System.out.println();

        classifier.buildClassifier(dataset);

    } catch (IOException ex) {
        Logger.getLogger(CISH.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(CISH.class.getName()).log(Level.SEVERE, null, ex);
    }
}