Package fr.lip6.jkernelmachines.test.density

Examples of fr.lip6.jkernelmachines.test.density.SDCADensityTest


   * {@link fr.lip6.jkernelmachines.density.SDCADensity#train(java.util.List)}
   * .
   */
  @Test
  public final void testTrainListOfT() {
    DoubleGaussL2 k = new DoubleGaussL2();
    SDCADensity<double[]> de = new SDCADensity<double[]>(k);
    de.setC(1.);
    de.train(train);
   
    for (double[] x : train) {
View Full Code Here


   
    GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0);
    train = g.generateList(10);
   
    svm = new GradMKL<double[]>();
    svm.addKernel(new DoubleGaussL2());
  }
View Full Code Here

  /**
   * Test method for {@link fr.lip6.jkernelmachines.classifier.GradMKL#addKernel(fr.lip6.jkernelmachines.kernel.Kernel)}.
   */
  @Test
  public final void testAddKernel() {
    DoubleGaussL2 k = new DoubleGaussL2(1.0);
    svm.addKernel(k);
    assertTrue(svm.getKernels().contains(k));
  }
View Full Code Here

  /**
   * Test method for {@link fr.lip6.jkernelmachines.classifier.GradMKL#setClassifier(fr.lip6.jkernelmachines.classifier.KernelSVM)}.
   */
  @Test
  public final void testSetClassifier() {
    LaSVM<double[]> lasvm = new LaSVM<double[]>(new DoubleGaussL2());
    svm.setClassifier(lasvm);
    assertEquals(lasvm, svm.getClassifier());
  }
View Full Code Here

   
    GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0);
    train = g.generateList(10);
   
    svm = new SimpleMKL<double[]>();
    svm.addKernel(new DoubleGaussL2());
  }
View Full Code Here

  /**
   * Test method for {@link fr.lip6.jkernelmachines.classifier.SimpleMKL#addKernel(fr.lip6.jkernelmachines.kernel.Kernel)}.
   */
  @Test
  public final void testAddKernel() {
    DoubleGaussL2 k = new DoubleGaussL2(1.0);
    svm.addKernel(k);
    assertTrue(svm.getKernels().contains(k));
  }
View Full Code Here

  /**
   * Test method for {@link fr.lip6.jkernelmachines.classifier.SimpleMKL#setClassifier(fr.lip6.jkernelmachines.classifier.KernelSVM)}.
   */
  @Test
  public final void testSetClassifier() {
    LaSVM<double[]> lasvm = new LaSVM<double[]>(new DoubleGaussL2());
    svm.setClassifier(lasvm);
    assertEquals(lasvm, svm.getClassifier());
  }
View Full Code Here

          .getSelectedItem().toString())) {
        k = new DoublePolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      } else if ("HPlolynomial".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoubleHPolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      }

      LaSVM<double[]> svm = new LaSVM<double[]>(k);
      svm.setC(Double.parseDouble(regularizationField.getText()));
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
      double[] alphas = svm.getAlphas();
      int sv = 0;
      for (int s = 0; s < alphas.length; s++) {
        if (alphas[s] != 0) {
          sv++;
        }
      }
      svLabel.setText("" + sv);
      validate();
      // save current classifier
      model.classifier = svm;
    } else if ("smo".equalsIgnoreCase(classifierBox.getSelectedItem()
        .toString())) {
      Kernel<double[]> k = new DoubleLinear();
      if ("GaussianL2".equalsIgnoreCase(kernelBox.getSelectedItem()
          .toString())) {
        k = new DoubleGaussL2(Double.parseDouble(kernelParamTextField
            .getText()));
      } else if ("TriangleL2".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoubleTriangleL2(
            Double.parseDouble(kernelParamTextField.getText()));
      } else if ("Polynomial".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoublePolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      } else if ("HPlolynomial".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoubleHPolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      }

      SMOSVM<double[]> svm = new SMOSVM<double[]>(k);
      svm.setC(Double.parseDouble(regularizationField.getText()));
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
      double[] alphas = svm.getAlphas();
      int sv = 0;
      for (int s = 0; s < alphas.length; s++) {
        if (alphas[s] != 0) {
          sv++;
        }
      }
      svLabel.setText("" + sv);
      validate();
      // save current classifier
      model.classifier = svm;
    } else if ("sag".equalsIgnoreCase(classifierBox.getSelectedItem()
        .toString())) {
      DoubleSAG svm = new DoubleSAG();
      svm.setLambda(1. / (train.size() * Double
          .parseDouble(regularizationField.getText())));
      svm.setE(10);
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
      svLabel.setText("N/A");

      // save current classifier
      model.classifier = svm;
    } else if ("pegasos".equalsIgnoreCase(classifierBox.getSelectedItem()
        .toString())) {
      DoublePegasosSVM svm = new DoublePegasosSVM();

      svm.setLambda(1. / (train.size() * Double
          .parseDouble(regularizationField.getText())));
      svm.setK(train.size() / 20);
      svm.setT(10 * train.size());
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
      svLabel.setText("N/A");

      // save current classifier
      model.classifier = svm;
    } else if ("simplemkl".equalsIgnoreCase(classifierBox.getSelectedItem()
        .toString())) {
      SimpleMKL<double[]> svm = new SimpleMKL<double[]>();
      svm.setC(Double.parseDouble(regularizationField.getText()));

      double[] G = { 0.05, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6 };
//      int dim = train.get(0).sample.length;
      for (double g : G) {
        svm.addKernel(new DoubleGaussL2(g));
//        // for(int i = 0 ; i < dim ; i++) {
//        // IndexDoubleGaussL2 k = new IndexDoubleGaussL2(i);
//        // k.setGamma(g);
//        // svm.addKernel(k);
//        // }
      }
      for (int d = 1; d < 5; d++) {
        svm.addKernel(new DoublePolynomial(d));
        svm.addKernel(new DoubleHPolynomial(d));
      }
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
View Full Code Here

          i++;

          if (args[i].equalsIgnoreCase("gauss")) {
            kernel = new DoubleGaussL2();
          } else {
            kernel = new DoubleLinear();
          }
        }
        // algorithm
        else if (args[i].equalsIgnoreCase("-a")) {
          i++;
View Full Code Here

    }

    // train model
    if ("lasvm"
        .equalsIgnoreCase(classifierBox.getSelectedItem().toString())) {
      Kernel<double[]> k = new DoubleLinear();
      if ("GaussianL2".equalsIgnoreCase(kernelBox.getSelectedItem()
          .toString())) {
        k = new DoubleGaussL2(Double.parseDouble(kernelParamTextField
            .getText()));
      } else if ("TriangleL2".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoubleTriangleL2(
            Double.parseDouble(kernelParamTextField.getText()));
      } else if ("Polynomial".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoublePolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      } else if ("HPlolynomial".equalsIgnoreCase(kernelBox
          .getSelectedItem().toString())) {
        k = new DoubleHPolynomial(Integer.parseInt(kernelParamTextField
            .getText()));
      }

      LaSVM<double[]> svm = new LaSVM<double[]>(k);
      svm.setC(Double.parseDouble(regularizationField.getText()));
      svm.train(localTrain);

      // info
      classnameLabel.setText(svm.getClass().getSimpleName());
      double[] alphas = svm.getAlphas();
      int sv = 0;
      for (int s = 0; s < alphas.length; s++) {
        if (alphas[s] != 0) {
          sv++;
        }
      }
      svLabel.setText("" + sv);
      validate();
      // save current classifier
      model.classifier = svm;
    } else if ("smo".equalsIgnoreCase(classifierBox.getSelectedItem()
        .toString())) {
      Kernel<double[]> k = new DoubleLinear();
      if ("GaussianL2".equalsIgnoreCase(kernelBox.getSelectedItem()
          .toString())) {
        k = new DoubleGaussL2(Double.parseDouble(kernelParamTextField
            .getText()));
      } else if ("TriangleL2".equalsIgnoreCase(kernelBox
View Full Code Here

TOP

Related Classes of fr.lip6.jkernelmachines.test.density.SDCADensityTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.