List of usage examples for weka.core.converters CSVSaver setDestination
@Override public void setDestination(File file) throws IOException
From source file:com.kdcloud.engine.embedded.node.ConsoleOutput.java
License:Open Source License
@Override public void run() throws Exception { CSVSaver saver = new CSVSaver(); saver.setInstances(input.getInstances()); saver.setDestination(System.out); saver.writeBatch();/*w ww. j av a 2 s .c o m*/ }
From source file:org.tigr.microarray.mev.cluster.gui.impl.bn.WekaUtil.java
License:Open Source License
/** * The <code>writeDataToCSVFile</code> method is given a WEKA Instances object and the name of the output file name * and writes the given WEKA data to the output file in CSV format. * @param data an <code>Instances</code> corresponding to a WEKA Instances object containing data * @param csvFileName a <code>String</code> denoting the name of the file where the given data * will be written in CSV format.// w w w . java2 s. c om * In this application, with GenBank accessions (GB) in the X dimension and samples in the Y dimension * <br> * The format of the given gene expression matrix data file should be: * <br> * CLASS\tGB_1\tGB_2\t...\tGB_n * <br> * sample_1\texpr_1_1\texpr_2_1\t...\texpr_n_1 * <br> * ... * <br> * sample_n\texpr_1_n\texpr_2_n\t...\texpr_n_n * <br> * where expr_i_j means expression of gene i in sample j * <br> * * @exception NullArgumentException if an error occurs because the given data is null. */ public static void writeDataToCSVFile(Instances data, String csvFileName) throws NullArgumentException { if (data == null) { throw new NullArgumentException("Parameter data passed to writeDataToCSVFile method was null!"); } try { CSVSaver saver = new CSVSaver(); saver.setInstances(data); saver.setFile(new File(csvFileName)); saver.setDestination(new File(csvFileName)); saver.writeBatch(); } catch (IOException ioe) { System.out.println(ioe); } }