sonar_tutorial_part4 - morinim/ultra GitHub Wiki
Choosing a different evaluator
Ultra comes with different pre-packaged evaluators: for classification tasks the default one is based on Gaussian distributions.
Usually, it's a good and versatile evaluator since it can handle multiclass classification problems.
However the sonar problem is a binary classification problem and could benefit from a specific evaluator: the binary_evaluator.
Now, consider another variant of the original source code:
src::basic_search<alps_es, src::binary_evaluator<gp::individual>> s(prob);
s.validation_strategy<src::holdout_validation>(prob);
const auto result(s.run(5));
std::cout << "\nCANDIDATE SOLUTION\n"
<< out::c_language << result.best_individual
<< "\n\nACCURACY\n" << *result.best_measurements.accuracy * 100.0
<< '%'
<< "\n\nFITNESS\n" << *result.best_measurements.fitness << '\n';
(full example in examples/sonar05.cc)
Here we use the src::basic_search class (instead of the usual src::search) because we want to specify the evaluator.
src::basic_search also allows specifying the evolution strategy. In this case, we use alps_es, which is the same strategy used by src::search and generally shouldn't be altered.