Example usage for weka.experiment InstanceQuery setDebug

List of usage examples for weka.experiment InstanceQuery setDebug

Introduction

In this page you can find the example usage for weka.experiment InstanceQuery setDebug.

Prototype

public void setDebug(boolean d) 

Source Link

Document

Sets whether there should be printed some debugging output to stderr or not.

Usage

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

License:Open Source License

/**
 * Loads the experimental results.//  w  w  w  .ja v a  2s.  c o  m
 *
 * @param exp      the experiment to evaluate
 * @return      the results
 * @throws Exception    If reading fails.
 */
protected Instances getData(weka.experiment.Experiment exp) throws Exception {
    Instances result;
    String tmpStr;
    DatabaseResultListener dbListener;
    InstanceQuery query;

    // load experiment data
    if (exp.getResultListener() instanceof CSVResultListener) {
        try {
            result = DataSource
                    .read(((CSVResultListener) exp.getResultListener()).getOutputFile().getAbsolutePath());
        } catch (Exception e) {
            getLogger().log(Level.SEVERE, "Failed to get instances from CSV:", e);
            throw new Exception("Error reading experiment from file:\n" + e);
        }
    } else if (exp.getResultListener() instanceof DatabaseResultListener) {
        dbListener = (DatabaseResultListener) exp.getResultListener();
        try {
            tmpStr = dbListener.getResultsTableName(exp.getResultProducer());
            query = new InstanceQuery();
            query.setDatabaseURL(dbListener.getDatabaseURL());
            query.setUsername(dbListener.getUsername());
            query.setPassword(dbListener.getPassword());
            query.setDebug(dbListener.getDebug());
            query.connectToDatabase();
            result = query.retrieveInstances("SELECT * FROM " + tmpStr);
            query.disconnectFromDatabase();
        } catch (Exception e) {
            getLogger().log(Level.SEVERE, "Failed to get instances from database:", e);
            throw new Exception("Error reading experiment from database:\n" + e);
        }
    } else {
        throw new Exception(
                "Unsupported ResultListener '" + exp.getResultListener().getClass().getName() + "'!");
    }

    return result;
}