Example usage for weka.core.converters Loader setSource

List of usage examples for weka.core.converters Loader setSource

Introduction

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

Prototype

void setSource(InputStream input) throws IOException;

Source Link

Document

Resets the Loader object and sets the source of the data set to be the supplied InputStream.

Usage

From source file:com.kdcloud.lib.rest.ext.AbstractInstancesRepresentation.java

License:Open Source License

public Instances getInstances() throws IOException {
    if (instances == null) {
        if (representation == null)
            throw new IOException("instances is null");
        if (representation instanceof AbstractInstancesRepresentation)
            instances = ((AbstractInstancesRepresentation) representation).getInstances();
        else {//  w w w .  j  a v  a  2  s.  c o m
            Loader loader = getLoader();
            loader.setSource(representation.getStream());
            instances = loader.getDataSet();
        }
    }
    return instances;
}

From source file:sirius.trainer.step3.SelectFeaturePane.java

License:Open Source License

/**
 * Applies the selected converter/*  w ww  .j  a  va  2  s  .co m*/
 *
 * @param cnv the converter to apply to the input file
 * @param f the input file
 */
private void tryConverter(final Loader cnv, final File f) {
    if (applicationData.getOneThread() == null) {
        applicationData.setOneThread(new Thread() {
            public void run() {
                try {
                    cnv.setSource(f);
                    Instances inst = cnv.getDataSet();
                    setDataset1Instances(inst);
                } catch (Exception ex) {
                    JOptionPane
                            .showMessageDialog(parent,
                                    cnv.getClass().getName() + " failed to load '" + f.getName() + "'.\n"
                                            + "Reason:\n" + ex.getMessage(),
                                    "Convert File", JOptionPane.ERROR_MESSAGE);
                    converterQuery(f);
                }
                applicationData.setOneThread(null);
            }
        });
        applicationData.getOneThread().setPriority(Thread.MIN_PRIORITY); // UI has most priority
        applicationData.getOneThread().start();
    }
}