Package fr.lip6.jkernelmachines.test.density

Source Code of fr.lip6.jkernelmachines.test.density.SMODensityTest

/**
    This file is part of JkernelMachines.

    JkernelMachines is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    JkernelMachines is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with JkernelMachines.  If not, see <http://www.gnu.org/licenses/>.

    Copyright David Picard - 2014

*/
package fr.lip6.jkernelmachines.test.density;

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import fr.lip6.jkernelmachines.density.SMODensity;
import fr.lip6.jkernelmachines.kernel.typed.DoubleGaussL2;
import fr.lip6.jkernelmachines.type.TrainingSample;
import fr.lip6.jkernelmachines.util.generators.GaussianGenerator;

/**
* Test case for the SMODensity class
* @author picard
*
*/
public class SMODensityTest {
  List<double[]> train;

  /**
   * @throws java.lang.Exception
   */
  @Before
  public void setUp() throws Exception {
    GaussianGenerator gen = new GaussianGenerator(2, 2, 1.0);
    List<TrainingSample<double[]>> list = gen.generateList(100, 100);
    train = new ArrayList<double[]>();
    for (TrainingSample<double[]> t : list) {
      train.add(t.sample);
    }
  }

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

    for (double[] x : train) {
      assertTrue(!Double.isNaN(de.valueOf(x)));
    }
  }

}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.