Here you can find the source of saveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
Parameter | Description |
---|---|
wr | PrintWriter |
coefficients | Coefficients |
labelNames | Label names |
public static void saveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
//package com.java2s; /*/* ww w. j a va 2 s . c o m*/ * This file is part of the MLDA. * * (c) Jose Maria Moyano Murillo * Eva Lucrecia Gibaja Galindo * Sebastian Ventura Soto <sventura@uco.es> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import java.io.PrintWriter; public class Main { /** * Save Chi and Phi coefficients as .csv file. They are stored in two different tables instead only one * * @param wr PrintWriter * @param coefficients Coefficients * @param labelNames Label names */ public static void saveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames) { //Save label names row String line; //Save Chi table line = "Chi;"; for (String labelName : labelNames) { line += labelName + ";"; } wr.write(line); wr.write(System.getProperty("line.separator")); for (int i = 0; i < labelNames.length; i++) { line = ""; line += labelNames[i] + ";"; for (int j = 0; j < coefficients[i].length; j++) { if (i >= j) { if (coefficients[j][i] == 0.0) { line += "" + ";"; } else { line += coefficients[j][i] + ";"; } } else { if (coefficients[i][j] == 0.0) { line += "" + ";"; } else { line += coefficients[i][j] + ";"; } } } wr.write(line); wr.write(System.getProperty("line.separator")); } //Save Phi table wr.write(System.getProperty("line.separator")); wr.write(System.getProperty("line.separator")); line = "Phi;"; for (String labelName : labelNames) { line += labelName + ";"; } wr.write(line); wr.write(System.getProperty("line.separator")); for (int i = 0; i < labelNames.length; i++) { line = ""; line += labelNames[i] + ";"; for (int j = 0; j < coefficients[i].length; j++) { if (j >= i) { if (coefficients[j][i] == 0.0) { line += "" + ";"; } else { line += coefficients[j][i] + ";"; } } else { if (coefficients[i][j] == 0.0) { line += "" + ";"; } else { line += coefficients[i][j] + ";"; } } } wr.write(line); wr.write(System.getProperty("line.separator")); } } }