Examples of train()


Examples of aima.core.learning.framework.Learner.train()

    return tree;
  }

  private ConstantDecisonTree majorityValue(DataSet ds) {
    Learner learner = new MajorityLearner();
    learner.train(ds);
    return new ConstantDecisonTree(learner.predict(ds.getExample(0)));
  }

  private String chooseAttribute(DataSet ds, List<String> attributeNames) {
    double greatestGain = 0.0;
View Full Code Here

Examples of aima.core.learning.learners.AdaBoostLearner.train()

        DecisionTree sl = (DecisionTree) stump;
        StumpLearner stumpLearner = new StumpLearner(sl, "No");
        learners.add(stumpLearner);
      }
      AdaBoostLearner learner = new AdaBoostLearner(learners, ds);
      learner.train(ds);
      int[] result = learner.test(ds);
      System.out
          .println("\nThis Ensemble Learner  classifies the data set with "
              + result[0]
              + " successes"
View Full Code Here

Examples of aima.core.learning.learners.CurrentBestLearner.train()

  @Test
  public void testCurrentBestLearnerOnRestaurantDataSet() throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    CurrentBestLearner learner = new CurrentBestLearner("Yes");
    learner.train(ds);

    int[] result = learner.test(ds);
    Assert.assertEquals(12, result[0]);
    Assert.assertEquals(0, result[1]);
  }
View Full Code Here

Examples of aima.core.learning.learners.DecisionListLearner.train()

          .println("DecisionList Demo - Inducing a DecisionList from the Restaurant DataSet\n ");
      System.out.println(Util.ntimes("*", 100));
      DataSet ds = DataSetFactory.getRestaurantDataSet();
      DecisionListLearner learner = new DecisionListLearner("Yes", "No",
          new DLTestFactory());
      learner.train(ds);
      System.out.println("The Induced DecisionList is");
      System.out.println(learner.getDecisionList());
      int[] result = learner.test(ds);

      System.out
View Full Code Here

Examples of aima.core.learning.learners.DecisionTreeLearner.train()

        .println("\nDecisionTree Demo - Inducing a DecisionList from the Restaurant DataSet\n ");
    System.out.println(Util.ntimes("*", 100));
    try {
      DataSet ds = DataSetFactory.getRestaurantDataSet();
      DecisionTreeLearner learner = new DecisionTreeLearner();
      learner.train(ds);
      System.out.println("The Induced Decision Tree is ");
      System.out.println(learner.getDecisionTree());
      int[] result = learner.test(ds);

      System.out
View Full Code Here

Examples of aima.core.learning.learners.MajorityLearner.train()

  @Test
  public void testMajorityLearner() throws Exception {
    MajorityLearner learner = new MajorityLearner();
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    learner.train(ds);
    int[] result = learner.test(ds);
    Assert.assertEquals(6, result[0]);
    Assert.assertEquals(6, result[1]);
  }
View Full Code Here

Examples of cc.mallet.fst.CRFTrainerByLabelLikelihood.train()

    CRF crf = new CRF (pipe, null);
    crf.addFullyConnectedStatesForLabels ();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
    TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
    for (int i = 0; i < 5; i++) {
      crft.train (training, 1);
      eval.evaluate(crft);
    }

    CRFExtractor extor = hackCrfExtor (crf);
    Extraction e1 = extor.extract (new ArrayIterator (data1));
View Full Code Here

Examples of cc.mallet.fst.CRFTrainerByLabelLikelihood.train()

      // train supervised
      if (numThreads == 1) {
        CRFTrainerByLabelLikelihood trainer = new CRFTrainerByLabelLikelihood(crf);
        trainer.setAddNoFactors(true);
        trainer.setGaussianPriorVariance(gpv);
        trainer.train(trainingSet,supIterations);
      }
      else {
        CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf,numThreads);
        trainer.setAddNoFactors(true);
        trainer.setGaussianPriorVariance(gpv);
View Full Code Here

Examples of cc.mallet.fst.CRFTrainerByLabelLikelihood.train()

      }
      else {
        CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf,numThreads);
        trainer.setAddNoFactors(true);
        trainer.setGaussianPriorVariance(gpv);
        trainer.train(trainingSet,supIterations);
        trainer.shutdown();
      }
      runEvaluators();
    }
   
View Full Code Here

Examples of cc.mallet.fst.CRFTrainerByStochasticGradient.train()

        + crf.averageTokenAccuracy(lists[1]));
    System.out.println("Training...");
    // either fixed learning rate or selected on a sample
    crft.setLearningRateByLikelihood(lists[0]);
    // crft.setLearningRate(0.01);
    crft.train(lists[0], 100);
    crf.print();
    System.out.println("Training Accuracy after training = "
        + crf.averageTokenAccuracy(lists[0]));
    System.out.println("Testing  Accuracy after training = "
        + crf.averageTokenAccuracy(lists[1]));
View Full Code Here
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.