本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}