14 using namespace shogun;
20 register_parameters();
27 register_parameters();
32 m_features = features;
72 REQUIRE(m_combination_rule != NULL,
"Combination rule is not set!");
78 #pragma omp parallel for num_threads(parallel->get_num_threads())
79 for (int32_t i = 0; i < m_num_bags; ++i)
84 float64_t* bag_results = output.get_column_vector(i);
98 REQUIRE(m_machine != NULL,
"Machine is not set!");
99 REQUIRE(m_bag_size > 0,
"Bag size is not set!");
100 REQUIRE(m_num_bags > 0,
"Number of bag is not set!");
112 ASSERT(m_bag_size < m_features->get_num_vectors());
119 m_all_oob_idx.
zero();
129 for (int32_t i = 0; i < m_num_bags; ++i)
154 c->
train(m_features);
169 void CBaggingMachine::register_parameters()
171 SG_ADD((
CSGObject**)&m_features,
"features",
"Train features for bagging",
177 "Combination rule to use for aggregating",
MS_AVAILABLE);
178 SG_ADD(&m_all_oob_idx,
"all_oob_idx",
"Indices of all oob vectors",
186 m_num_bags = num_bags;
196 m_bag_size = bag_size;
217 void CBaggingMachine::init()
222 m_combination_rule = NULL;
227 m_oob_indices = NULL;
234 m_combination_rule = rule;
239 SG_REF(m_combination_rule);
240 return m_combination_rule;
245 REQUIRE(m_combination_rule != NULL,
"Combination rule is not set!");
252 output.set_const(
NAN);
272 for (
index_t j = 0; j < oob.vlen; j++)
273 output(oob[j], i) = lv[j];
280 output.display_matrix();
285 if (m_all_oob_idx[i])
306 SG_ERROR(
"Unsupported label type\n");
325 if (out_of_bag[in_bag[i]])
327 out_of_bag[in_bag[i]] =
false;
334 for (
index_t i = 0; i < out_of_bag.vlen; i++)
339 m_all_oob_idx[i] =
true;