weka.experiment.CSVResultListener Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weka-dev Show documentation
Show all versions of weka-dev Show documentation
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This version represents the developer version, the
"bleeding edge" of development, you could say. New functionality gets added
to this version.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* CSVResultListener.java
* Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.experiment;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.RevisionHandler;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.gui.FilePropertyMetadata;
import javax.swing.*;
/**
* Takes results from a result producer and assembles
* them into comma separated value form.
*
*
*
* Valid options are:
*
*
*
* -O <file name>
* The filename where output will be stored. Use - for stdout.
* (default temp file)
*
*
*
*
* @author Len Trigg ([email protected])
* @version $Revision: 11690 $
*/
public class CSVResultListener implements ResultListener, OptionHandler,
RevisionHandler {
/** for serialization */
static final long serialVersionUID = -623185072785174658L;
/** The ResultProducer sending us results */
protected ResultProducer m_RP;
/** The destination output file, null sends to System.out */
protected File m_OutputFile = null;
/** The name of the output file. Empty for temporary file. */
protected String m_OutputFileName = "";
/** The destination for results (typically connected to the output file) */
protected transient PrintWriter m_Out = new PrintWriter(System.out, true);
/**
* Sets temporary file.
*/
public CSVResultListener() {
File resultsFile;
try {
resultsFile = File.createTempFile("weka_experiment", ".csv");
resultsFile.deleteOnExit();
} catch (Exception e) {
System.err.println("Cannot create temp file, writing to standard out.");
resultsFile = new File("-");
}
setOutputFile(resultsFile);
setOutputFileName("");
}
/**
* Returns a string describing this result listener
*
* @return a description of the result listener suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "Takes results from a result producer and assembles them into "
+ "comma separated value form.";
}
/**
* Returns an enumeration describing the available options..
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration
© 2015 - 2024 Weber Informatics LLC | Privacy Policy