當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeGP.fit方法代碼示例

本文整理匯總了Java中com.github.chen0040.gp.treegp.TreeGP.fit方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeGP.fit方法的具體用法?Java TreeGP.fit怎麽用?Java TreeGP.fit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.chen0040.gp.treegp.TreeGP的用法示例。


在下文中一共展示了TreeGP.fit方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test_symbolic_regression

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setDisplayEvery(2);
   Solution program = tgp.fit(trainingData);
   logger.info("global: {}", program.mathExpression());

   test(program, testingData, false);

}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:18,代碼來源:MexicanHatUnitTest.java

示例2: test_symbolic_regression_with_crossover_subtree_no_bias

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression_with_crossover_subtree_no_bias() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setCrossoverStrategy(TGPCrossoverStrategy.CROSSVOER_SUBTREE_NO_BIAS);

   Solution program = tgp.fit(trainingData);

   test(program, testingData, true);

}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:18,代碼來源:MexicanHatUnitTest.java

示例3: test_symbolic_regression_with_mutation_hoist

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression_with_mutation_hoist() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setMutationStrategy(TGPMutationStrategy.MUTATION_HOIST);

   Solution program = tgp.fit(trainingData);

   test(program, testingData, true);
}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:17,代碼來源:MexicanHatUnitTest.java

示例4: test_symbolic_regression_with_mutation_subtree_kinnear

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression_with_mutation_subtree_kinnear() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setMutationStrategy(TGPMutationStrategy.MUTATION_SUBTREE_KINNEAR);

   Solution program = tgp.fit(trainingData);

   test(program, testingData, true);

}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:18,代碼來源:MexicanHatUnitTest.java

示例5: test_symbolic_regression_replacement_mu_plus_lambda

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression_replacement_mu_plus_lambda() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setReplacementStrategy(TGPPopulationReplacementStrategy.MuPlusLambda);

   Solution program = tgp.fit(trainingData);

   test(program, testingData, true);

}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:18,代碼來源:MexicanHatUnitTest.java

示例6: test_symbolic_regression_pop_init_ptc_1

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_symbolic_regression_pop_init_ptc_1() {

   List<Observation> data = Tutorials.mexican_hat();
   CollectionUtils.shuffle(data);
   TupleTwo<List<Observation>, List<Observation>> split_data = CollectionUtils.split(data, 0.9);
   List<Observation> trainingData = split_data._1();
   List<Observation> testingData = split_data._2();

   TreeGP tgp = createTreeGP();
   tgp.setPopulationInitializationStrategy(TGPInitializationStrategy.INITIALIZATION_METHOD_PTC1);

   Solution program = tgp.fit(trainingData);

   test(program, testingData, true);

}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:18,代碼來源:MexicanHatUnitTest.java

示例7: test_simple

import com.github.chen0040.gp.treegp.TreeGP; //導入方法依賴的package包/類
@Test
public void test_simple(){
   TreeGP tgp = new TreeGP();
   tgp.getOperatorSet().addAll(new Concat());
   tgp.addConstants("Hello", "World", "Hi", "There", "Morning", "Me", "Good", "You", "to", "!");
   tgp.setVariableCount(0);

   tgp.setCostEvaluator((program, observations)->{
      double error = 0;
      for(Observation obs : observations){
         TextObservation observation = (TextObservation)obs;
         program.executeWithText(observation);
         String predicted_text = observation.getPredictedTextOutput(0);
         error += Math.max(0, observation.text.length() - evaluate(observation.text, predicted_text));
         error += (double)(predicted_text.length() - observation.text.length()) / observation.text.length();
      }

      return error;
   });
   tgp.setPopulationSize(1000);
   tgp.setDisplayEvery(2);
   tgp.setMaxGeneration(100); // should be 1000 for full evolution

   List<Observation> trainingData = new ArrayList<>();
   TextObservation target = new TextObservation("Hello World Good Morning to You !");
   trainingData.add(target);

   Solution solution = tgp.fit(trainingData);

   solution.executeWithText(target);

   System.out.println(target.getPredictedTextOutput(0));
}
 
開發者ID:chen0040,項目名稱:java-genetic-programming,代碼行數:34,代碼來源:TextGeneratorUnitTest.java


注:本文中的com.github.chen0040.gp.treegp.TreeGP.fit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。