Example usage for weka.experiment Experiment getDatasets

List of usage examples for weka.experiment Experiment getDatasets

Introduction

In this page you can find the example usage for weka.experiment Experiment getDatasets.

Prototype

public DefaultListModel getDatasets() 

Source Link

Document

Gets the datasets in the experiment.

Usage

From source file:adams.flow.transformer.WekaExperiment.java

License:Open Source License

/**
 * Executes the flow item./*from w ww  .  j  ava 2s  .com*/
 *
 * @return      null if everything is fine, otherwise error message
 */
@Override
protected String doExecute() {
    String result;
    weka.experiment.Experiment exp;
    String[] files;
    int i;

    result = null;

    // load experiment
    try {
        exp = weka.experiment.Experiment.read(m_ExperimentFile.getAbsolutePath());
    } catch (Exception e) {
        exp = null;
        result = handleException("Failed to read experiment: " + m_ExperimentFile, e);
    }

    // more datasets to add?
    if (m_InputToken != null) {
        // get files
        files = FileUtils.toStringArray(m_InputToken.getPayload());

        // add files
        if (isLoggingEnabled())
            getLogger().info("Adding files: " + files);
        for (i = 0; i < files.length; i++)
            exp.getDatasets().addElement(new File(files[i]));
    }

    // run experiment
    if (result == null) {
        try {
            if (isLoggingEnabled())
                getLogger().info("Initializing experiment...");
            exp.initialize();

            if (isLoggingEnabled())
                getLogger().info("Running experiment...");
            exp.runExperiment();

            if (isLoggingEnabled())
                getLogger().info("Post-processing experiment...");
            exp.postProcess();

            if (isLoggingEnabled())
                getLogger().info("Finished experiment!");

            m_OutputToken = new Token(exp);
        } catch (Exception e) {
            result = handleException("Failed execute experiment: " + m_ExperimentFile, e);
        }
    }

    return result;
}