本文整理汇总了Java中com.github.chen0040.gp.commons.BasicObservation类的典型用法代码示例。如果您正苦于以下问题:Java BasicObservation类的具体用法?Java BasicObservation怎么用?Java BasicObservation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicObservation类属于com.github.chen0040.gp.commons包,在下文中一共展示了BasicObservation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.github.chen0040.gp.commons.BasicObservation; //导入依赖的package包/类
public double[] execute(double[] input){
BasicObservation fitnessCase = new BasicObservation(input.length, input.length);
execute(fitnessCase);
double[] output = new double[input.length];
for(int i=0; i < output.length; ++i) {
output[i] = fitnessCase.getOutput(i);
}
return output;
}
示例2: spiral
import com.github.chen0040.gp.commons.BasicObservation; //导入依赖的package包/类
private List<Observation> spiral() throws IOException {
List<Observation> result = new ArrayList<>();
InputStream inputStream = FileUtil.getResource("spiral-dataset.txt");
try(BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))){
String line;
boolean firstLine = true;
while((line = reader.readLine()) != null){
if(firstLine){
firstLine = false;
continue;
}
String[] parts = line.split("\t");
double x = Double.parseDouble(parts[0]);
double y = Double.parseDouble(parts[1]);
int label = Integer.parseInt(parts[2]);
Observation observation = new BasicObservation(2, 2);
observation.setInput(0, x);
observation.setInput(1, y);
observation.setOutput(0, label == -1 ? 1 : 0);
observation.setOutput(1, label != -1 ? 1 : 0);
result.add(observation);
}
}catch(IOException ioe){
logger.error("Failed to read spiral-dataset.txt", ioe);
}
return result;
}