本文整理汇总了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));
}