Example usage for weka.core.converters LibSVMLoader LibSVMLoader

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

Introduction

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

Prototype

LibSVMLoader

Source Link

Usage

From source file:adams.data.io.input.LibSVMSpreadSheetReader.java

License:Open Source License

/**
 * Returns an instance of the file loader.
 * /*  ww  w  .  j av  a2 s .co  m*/
 * @return      the file loader
 */
@Override
protected AbstractFileLoader newLoader() {
    return new LibSVMLoader();
}

From source file:cish.CISH.java

private void trainClassifier() {
    try {/*from   ww w.  jav a  2 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);
    }
}