Gaussian Mixture Model for estimating the density on arrays of double.
The initialization of the Gaussian centers is performed by k-means, then the EM algorithm runs until the centers stabilize.
454647484950515253
public void setUp() throws Exception { GaussianGenerator g = new GaussianGenerator(10, 5.0f, 0.1); train = g.generateList(50); DoubleGaussL2 k = new DoubleGaussL2(1.0); svm = new LaSVM<double[]>(k); svm.setC(1.0); }
636465666768697071727374
System.out.println("Samples generated"); // 3. train svm long time = System.currentTimeMillis(); // Kernel<double[]> k = new DoubleLinear(); DoubleGaussL2 k = new DoubleGaussL2(); k.setGamma(2); SMODensity<double[]> svm = new SMODensity<double[]>(k); svm.setC(100); svm.train(train); long smotime = System.currentTimeMillis() - time; System.out.println("SMO done in " + smotime);
4849505152535455
public void setUp() throws Exception { GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0); train = g.generateList(10); DoubleGaussL2 k = new DoubleGaussL2(1.0); svm = new LaSVMI<double[]>(k); }
575859606162636465
/** * Test method for {@link fr.lip6.jkernelmachines.classifier.LaSVMI#LaSVMI(fr.lip6.jkernelmachines.kernel.Kernel)}. */ @Test public final void testLaSVMI() { DoubleGaussL2 k = new DoubleGaussL2(1.0); svm = new LaSVMI<double[]>(k); assertEquals(k, svm.getKernel()); }
979899100101102103104105
/** * Test method for {@link fr.lip6.jkernelmachines.classifier.LaSVMI#setKernel(fr.lip6.jkernelmachines.kernel.Kernel)}. */ @Test public final void testSetKernel() { DoubleGaussL2 k = new DoubleGaussL2(); svm.setKernel(k); assertEquals(k, svm.getKernel()); }
5758596061626364656667
* Test method for * {@link fr.lip6.jkernelmachines.density.SMODensity#train(java.util.List)}. */ @Test public final void testTrainListOfT() { DoubleGaussL2 k = new DoubleGaussL2(); ParzenDensity<double[]> de = new ParzenDensity<double[]>(k); de.train(train); for (double[] x : train) { assertTrue(!Double.isNaN(de.valueOf(x)));
4142434445464748
public void setUp() throws Exception { GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0); train = g.generateList(10); DoubleGaussL2 k = new DoubleGaussL2(1.0); svm = new LaSVM<double[]>(k); }
747576777879808182
assertEquals(1.0, svm.getB(), 1e-15); } @Test public final void testSetKernel() { DoubleGaussL2 k = new DoubleGaussL2(); svm.setKernel(k); assertEquals(k, svm.getKernel()); }
676869707172737475767778
DataPreProcessing.centerList(trainlist); DataPreProcessing.reduceList(trainlist); DataPreProcessing.normalizeList(trainlist); //learning DoubleGaussL2 kernel = new DoubleGaussL2(); kernel.setGamma(2.0); LaSVM<double[]> svm = new LaSVM<double[]>(kernel); svm.setC(10); svm.setE(5); AccuracyEvaluator<double[]> accev = new AccuracyEvaluator<double[]>();
5960616263646566676869
* {@link fr.lip6.jkernelmachines.density.SDCADensity#train(java.lang.Object)} * . */ @Test public final void testTrainT() { DoubleGaussL2 k = new DoubleGaussL2(); SDCADensity<double[]> de = new SDCADensity<double[]>(k); de.train(train.get(0)); for (double[] x : train) { assertTrue(!Double.isNaN(de.valueOf(x)));