@Test(expected = Test.None.class) public void testLongley() throws Exception { System.out.println("longley"); double[] prediction = LOOCV.regression(Longley.x, Longley.y, (x, y) -> SVR.fit(x, y, 2.0, 10.0, 1E-3)); double rmse = RMSE.of(Longley.y, prediction); System.out.println("LOOCV RMSE = " + rmse); assertEquals(1.6140026106705365, rmse, 1E-4); Regression<double[]> model = SVR.fit(Longley.x, Longley.y, 2.0, 10.0, 1E-3); java.nio.file.Path temp = smile.data.Serialize.write(model); smile.data.Serialize.read(temp); }
public static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol) { smile.base.svm.SVR<double[]> svr = new smile.base.svm.SVR<>(new LinearKernel(), eps, C, tol); KernelMachine<double[]> svm = svr.fit(x, y); return new Regression<double[]>() { LinearKernelMachine model = LinearKernelMachine.of(svm); @Override public double predict(double[] x) { return model.f(x); } }; }
SVR { public static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol) { smile.base.svm.SVR<double[]> svr = new smile.base.svm.SVR<>(new LinearKernel(), eps, C, tol); KernelMachine<double[]> svm = svr.fit(x, y); return new Regression<double[]>() { LinearKernelMachine model = LinearKernelMachine.of(svm); @Override public double predict(double[] x) { return model.f(x); } }; } }
SVR { public static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol) { smile.base.svm.SVR<double[]> svr = new smile.base.svm.SVR<>(new LinearKernel(), eps, C, tol); KernelMachine<double[]> svm = svr.fit(x, y); return new Regression<double[]>() { LinearKernelMachine model = LinearKernelMachine.of(svm); @Override public double predict(double[] x) { return model.f(x); } }; }  }
SVR { public static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol) { smile.base.svm.SVR<double[]> svr = new smile.base.svm.SVR<>(new LinearKernel(), eps, C, tol); KernelMachine<double[]> svm = svr.fit(x, y); return new Regression<double[]>() { LinearKernelMachine model = LinearKernelMachine.of(svm); @Override public double predict(double[] x) { return model.f(x); } }; }  static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol); static Regression<int[]> fit(int[][] x, double[] y, int p, double eps, double C, double tol); static Regression<SparseArray> fit(SparseArray[] x, double[] y, int p, double eps, double C, double tol); static KernelMachine<T> fit(T[] x, double[] y, MercerKernel<T> kernel, double eps, double C, double tol); }
SVR { public static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol) { smile.base.svm.SVR<double[]> svr = new smile.base.svm.SVR<>(new LinearKernel(), eps, C, tol); KernelMachine<double[]> svm = svr.fit(x, y); return new Regression<double[]>() { LinearKernelMachine model = LinearKernelMachine.of(svm); @Override public double predict(double[] x) { return model.f(x); } }; }  static Regression<double[]> fit(double[][] x, double[] y, double eps, double C, double tol); static Regression<int[]> fit(int[][] x, double[] y, int p, double eps, double C, double tol); static Regression<SparseArray> fit(SparseArray[] x, double[] y, int p, double eps, double C, double tol); static KernelMachine<T> fit(T[] x, double[] y, MercerKernel<T> kernel, double eps, double C, double tol);  }