本文整理汇总了C++中array_type::row方法的典型用法代码示例。如果您正苦于以下问题:C++ array_type::row方法的具体用法?C++ array_type::row怎么用?C++ array_type::row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array_type
的用法示例。
在下文中一共展示了array_type::row方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key
key_type key(const array_type & df, const std::size_t index) const
{
if (df.shape().second == 0)
{
return {0, 0};
}
else
{
const int prod_id = df[df.row(index)][0]; // TODO, hardcoded
const char segment = df[df.row(index)][8]; // TODO, hardcoded
return {prod_id, segment};
}
}
示例2: gb_test
//.........这里部分代码省略.........
);
const array_type i_test_data =
num::loadtxt(
std::move(i_testing),
std::move(
num::loadtxtCfg<real_type>()
.delimiter(',')
.converters(num::loadtxtCfg<real_type>::converters_type{converters_test})
)
);
std::vector<std::string> colnames;
array_type train_data;
array_type test_data;
std::tie(colnames, train_data, test_data) = gen_features(raw_colnames, i_train_data, i_test_data);
// std::cerr << train_data.shape() << test_data.shape() << std::endl;
// std::copy(colnames.cbegin(), colnames.cend(), std::ostream_iterator<std::string>(std::cerr, "\n"));
assert(train_data.shape().second == test_data.shape().second + 1);
const array_type::varray_type train_y_valarr = train_data[train_data.column(colidx(colnames, "SPECIAL_PART"))];
const std::vector<float> train_y(std::begin(train_y_valarr), std::end(train_y_valarr));
std::cerr << "train_y size: " << train_y.size() << std::endl;
train_data = num::del_column(train_data, colidx(colnames, "SPECIAL_PART"));
colnames.erase(std::find(colnames.begin(), colnames.end(), "SPECIAL_PART"));
assert(colnames.size() == train_data.shape().second);
std::cerr << "train_data shape: " << train_data.shape() << std::endl;
std::cerr << "test_data shape: " << test_data.shape() << std::endl;
const std::map<const std::string, const std::string> * PARAMS_SET__no[] = {¶ms::no::prov47};
std::vector<float> train_y__no;
std::transform(train_y.cbegin(), train_y.cend(), std::back_inserter(train_y__no),
[](const float what)
{
// quantize train y vector into {0,1}
return what >= 0.5 ? 1. : 0.;
}
);
const auto y_hat_no = run_binary_estimators(
std::begin(PARAMS_SET__no), std::end(PARAMS_SET__no),
time0, train_data, train_y__no, test_data);
////////////////////////////////////////////////////////////////////////////
std::vector<std::size_t> y_hat(y_hat_no);
const std::string yes_no_maybe[] = {"No", "Maybe", "Yes"};
std::map<int, std::pair<std::string, std::string>> responses;
GroupBy gb_test(i_test_data);
int ix{0};
for (auto group = gb_test.yield(); group.size() != 0; group = gb_test.yield())
{
const std::valarray<real_type> row = i_test_data[i_test_data.row(group.front())];
const int prod_id = row[colidx(raw_colnames, "PRODUCT_NUMBER")];
const char segment = row[colidx(raw_colnames, "CUSTOMER_SEGMENT1")];
const auto response = y_hat[ix++];
if (responses.count(prod_id))
{
if (segment == 0)
{
responses[prod_id].first = yes_no_maybe[response];
}
else
{
responses[prod_id].second = yes_no_maybe[response];
}
}
else
{
if (segment == 0)
{
responses[prod_id] = {yes_no_maybe[response], "NA"};
}
else
{
responses[prod_id] = {"NA", yes_no_maybe[response]};
}
}
}
std::vector<std::string> str_y_hat;
std::transform(responses.cbegin(), responses.cend(), std::back_inserter(str_y_hat),
[](const std::pair<int, std::pair<std::string, std::string>> & kv)
{
return std::to_string(kv.first) + ',' + kv.second.first + ',' + kv.second.second;
}
);
return str_y_hat;
}