public static void main(String[] args) throws IOException { RegressionInputs inputs = Conversion.toRegressionInputs(getInputs()); Parameters params = getParams(); RegressionSVM svm = LazySVM.loadOrTrainRegression("generated", params, inputs); System.out.println("Maybe reused a trained svm!"); openChart(getRegressionChart(svm, inputs)); }
/** *************************************************** */ public static RegressionInputs loadRegressionCsv(String filename) throws IOException { CSVReader reader = new CSVReader(new FileReader(filename)); String[] nextLine; Vector<svm_node[]> x = new Vector<svm_node[]>(); Vector<Double> y = new Vector<Double>(); while ((nextLine = reader.readNext()) != null) { int m = nextLine.length; svm_node[] xk = new svm_node[m - 1]; for (int i = 0; i < m - 1; i++) xk[i] = Conversion.toVector(i, Double.parseDouble(nextLine[i])); x.add(xk); y.add(Double.parseDouble(nextLine[m - 1])); } reader.close(); return new RegressionInputs(x, y); }
public static Coord3d[] getInputs() { return Conversion.toArray(SphereScatterGenerator.generate(new Coord3d(0, 0, 0), 1, 20, true)); }