本文整理汇总了C++中DynArray::get_array方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::get_array方法的具体用法?C++ DynArray::get_array怎么用?C++ DynArray::get_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::get_array方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_oob_error
float64_t CBaggingMachine::get_oob_error(CEvaluation* eval) const
{
REQUIRE(m_combination_rule != NULL, "Combination rule is not set!");
REQUIRE(m_bags->get_num_elements() > 0, "BaggingMachine is not trained!");
SGMatrix<float64_t> output(m_features->get_num_vectors(), m_bags->get_num_elements());
if (m_labels->get_label_type() == LT_REGRESSION)
output.zero();
else
output.set_const(NAN);
/* TODO: add parallel support of applying the OOBs
only possible when add_subset is thread-safe
#pragma omp parallel for num_threads(parallel->get_num_threads())
*/
for (index_t i = 0; i < m_bags->get_num_elements(); i++)
{
CMachine* m = dynamic_cast<CMachine*>(m_bags->get_element(i));
CDynamicArray<index_t>* current_oob
= dynamic_cast<CDynamicArray<index_t>*>(m_oob_indices->get_element(i));
SGVector<index_t> oob(current_oob->get_array(), current_oob->get_num_elements(), false);
oob.display_vector();
m_features->add_subset(oob);
CLabels* l = m->apply(m_features);
SGVector<float64_t> lv = l->get_values();
// assign the values in the matrix (NAN) that are in-bag!
for (index_t j = 0; j < oob.vlen; j++)
output(oob[j], i) = lv[j];
m_features->remove_subset();
SG_UNREF(current_oob);
SG_UNREF(m);
SG_UNREF(l);
}
output.display_matrix();
DynArray<index_t> idx;
for (index_t i = 0; i < m_features->get_num_vectors(); i++)
{
if (m_all_oob_idx[i])
idx.push_back(i);
}
SGVector<float64_t> combined = m_combination_rule->combine(output);
CLabels* predicted = NULL;
switch (m_labels->get_label_type())
{
case LT_BINARY:
predicted = new CBinaryLabels(combined);
break;
case LT_MULTICLASS:
predicted = new CMulticlassLabels(combined);
break;
case LT_REGRESSION:
predicted = new CRegressionLabels(combined);
break;
default:
SG_ERROR("Unsupported label type\n");
}
m_labels->add_subset(SGVector<index_t>(idx.get_array(), idx.get_num_elements(), false));
float64_t res = eval->evaluate(predicted, m_labels);
m_labels->remove_subset();
return res;
}