Skip to content

Commit

Permalink
Fixed missing taskflow. simple test to see if validation is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
gAldeia committed Apr 25, 2024
1 parent bd6a5d4 commit d3538e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
- ninja
- ceres-solver=2.1.0
- pybind11>=2.6.2
- taskflow
- pytest #=6.2.4
- pydot
- scikit-learn
Expand Down
7 changes: 3 additions & 4 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ bool Engine<T>::update_best(const Dataset& data, bool val)
//std::cout << ind.program.get_model() << std::endl;

//std::cout << "got individual of rank" << ind.fitness.rank << std::endl;
if (val)
f = ind.fitness.loss_v;
else
f = ind.fitness.loss;

// if there is no validation, then loss_v == loss and this should work just fine
f = ind.fitness.loss_v;

if (f*error_weight > bs*error_weight
|| (f == bs && ind.fitness.complexity < this->best_complexity)
Expand Down
11 changes: 10 additions & 1 deletion tests/cpp/test_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,19 @@ TEST(Engine, EngineWorks)

params.set_verbosity(2); // TODO: verbosity tests

// checking if validation size works
params.set_validation_size(0.2);

std::cout << "n jobs = 1" << std::endl;
params.set_n_jobs(1);
Brush::RegressorEngine est5(params);
est5.run(data);
est5.run(data); // this will not use validation size from parameters
std::cout << "best individual using run(data)" << std::endl;
std::cout << est5.best_ind.program.get_model() << std::endl;

est5.fit(X, y); // this will use validation size from parameters
std::cout << "best individual using fit(X, y)" << std::endl;
std::cout << est5.best_ind.program.get_model() << std::endl;

std::cout << "n jobs = 2" << std::endl;
params.set_n_jobs(2);
Expand Down

0 comments on commit d3538e3

Please sign in to comment.