本文整理汇总了C++中Index::docs方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::docs方法的具体用法?C++ Index::docs怎么用?C++ Index::docs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::docs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_cv
void check_cv(Index& idx, Classifier& c, double min_accuracy)
{
std::vector<doc_id> docs = idx.docs();
classify::confusion_matrix mtx = c.cross_validate(docs, 5);
ASSERT_GREATER(mtx.accuracy(), min_accuracy);
ASSERT_LESS(mtx.accuracy(), 100.0);
}
示例2: cv
classify::confusion_matrix cv(Index& idx, Classifier& c, bool even)
{
std::vector<doc_id> docs = idx.docs();
classify::confusion_matrix matrix;
auto seconds = common::time<std::chrono::seconds>(
[&]()
{
matrix = c.cross_validate(docs, 5, even);
});
std::cerr << "time elapsed: " << seconds.count() << "s" << std::endl;
matrix.print();
matrix.print_stats();
return matrix;
}
示例3: check_split
void check_split(Index& idx, Classifier& c, double min_accuracy)
{
// create splits
std::vector<doc_id> docs = idx.docs();
std::mt19937 gen(47);
std::shuffle(docs.begin(), docs.end(), gen);
size_t split_idx = docs.size() / 8;
std::vector<doc_id> train_docs{docs.begin() + split_idx, docs.end()};
std::vector<doc_id> test_docs{docs.begin(), docs.begin() + split_idx};
// train and test
c.train(train_docs);
classify::confusion_matrix mtx = c.test(test_docs);
ASSERT_GREATER(mtx.accuracy(), min_accuracy);
ASSERT_LESS(mtx.accuracy(), 100.0);
}
示例4: test_rank
void test_rank(Ranker& r, Index& idx, const std::string& encoding)
{
for (size_t i = 0; i < idx.num_docs(); ++i)
{
auto d_id = idx.docs()[i];
corpus::document query{idx.doc_path(d_id), doc_id{i}};
query.encoding(encoding);
auto ranking = r.score(idx, query);
ASSERT_EQUAL(ranking.size(), 10); // default is 10 docs
// since we're searching for a document already in the index, the same
// document should be ranked first, but there are a few duplicate
// documents......
if (ranking[0].first != i)
{
ASSERT_EQUAL(ranking[1].first, i);
ASSERT_APPROX_EQUAL(ranking[0].second, ranking[1].second);
}
}
}