SampleDatasetsClassificationTest.java :  » Natural-Language-Processing » MinorThird » edu » cmu » minorthird » classify » Java Open Source

Java Open Source » Natural Language Processing » MinorThird 
MinorThird » edu » cmu » minorthird » classify » SampleDatasetsClassificationTest.java
package edu.cmu.minorthird.classify;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.log4j.Logger;

/**
 *
 * This class is responsible for...
 *
 * @author ksteppe
 */
public class SampleDatasetsClassificationTest extends AbstractClassificationChecks
{
  Logger log = Logger.getLogger(this.getClass());

  /**
   * Standard test class constructior for SampleDatasetsClassificationTest
   * @param name Name of the test
   */
  public SampleDatasetsClassificationTest(String name)
  {
    super(name);
  }

  /**
   * Convinence constructior for SampleDatasetsClassificationTest
   */
  public SampleDatasetsClassificationTest()
  {
    super("SampleDatasetsClassificationTest");
  }

  /**
   * setUp to run before each test
   */
  protected void setUp()
  {
    Logger.getRootLogger().removeAllAppenders();
    org.apache.log4j.BasicConfigurator.configure();
    //TODO add initializations if needed
  }

  /**
   * clean up to run after each test
   */
  protected void tearDown()
  {
    //TODO clean up resources if needed
  }

  /**
   * Base test for SampleDatasetsClassificationTest
   */
  public void test()
  {
    Dataset train = SampleDatasets.toyBayesTrain();
    Dataset test = SampleDatasets.toyBayesTest();

    log.debug("train: \n" + train);
    log.debug("test: \n" + test);
    double[] expectedStats = new double[] {0d, 0d, 0d, 0d, 0d, 0d, 0d,
                                           1d, 1d,
                                           10.117528032481275,
                                           1d, 1d, 1d, 1d};

    super.checkClassify(DEFAULT_LEARNER, train, test, expectedStats);
  }

  /**
   * Creates a TestSuite from all testXXX methods
   * @return TestSuite
   */
  public static Test suite()
  {
    return new TestSuite(SampleDatasetsClassificationTest.class);
  }

  /**
   * Run the full suite of tests with text output
   * @param args - unused
   */
  public static void main(String args[])
  {
    junit.textui.TestRunner.run(suite());
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.