Skip to content

Commit

Permalink
Enable the oob_error observation.
Browse files Browse the repository at this point in the history
The OOB error is computed only if the combination rule and the evaluation
metric are specified. Moreover, there must be observers attached to the
machine.
  • Loading branch information
geektoni committed May 5, 2020
1 parent 37b7fe0 commit 9dfa8e4
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/shogun/machine/BaggingMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,25 @@ bool BaggingMachine::train_machine(std::shared_ptr<Features> data)
#pragma omp critical
{

// get out of bag indexes
auto oob = get_oob_indices(idx);
m_oob_indices.push_back(oob);

// add trained machine to bag array
m_bags.push_back(c);

// observe some variables
// auto oob_error = this->get_oob_error();
this->observe<std::shared_ptr<Machine>>(
i, "trained_machine", "Trained machine for this bag", c);
// this->observe<float64_t>(i, "oob_error", "Out-of-bag Error",
// oob_error);
// get out of bag indexes
auto oob = get_oob_indices(idx);
m_oob_indices.push_back(oob);

// add trained machine to bag array
m_bags.push_back(c);

// observe some variables. The oob error is computed only when when
// we have all the variables set and there are observers attached.
this->observe<std::shared_ptr<Machine>>(
i, "trained_machine", "Trained machine for this bag", c);

if (this->m_combination_rule && this->m_oob_evaluation_metric &&
this->get_num_subscriptions() != 0)
{
auto oob_error = this->get_oob_error();
this->observe<float64_t>(
i, "oob_error", "Out-of-bag Error", oob_error);
}
}

pb.print_progress();
Expand Down

0 comments on commit 9dfa8e4

Please sign in to comment.