本文整理汇总了C++中TrainingSet::add方法的典型用法代码示例。如果您正苦于以下问题:C++ TrainingSet::add方法的具体用法?C++ TrainingSet::add怎么用?C++ TrainingSet::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrainingSet
的用法示例。
在下文中一共展示了TrainingSet::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(NaiveBayesTest, test2) {
enum Bird {
SMALL,
MIDDLE,
BIG
};
TrainingSet<Bird, 2> trainingSet;
// weight, height
std::array<double, 2> s1 = {2, 10};
std::array<double, 2> s2 = {2.3, 12};
trainingSet.add(SMALL, s1);
trainingSet.add(SMALL, s2);
std::array<double, 2> m1 = {4, 15};
std::array<double, 2> m2 = {4.7, 17.2};
trainingSet.add(MIDDLE, m1);
trainingSet.add(MIDDLE, m2);
std::array<double, 2> b1 = {7, 23};
std::array<double, 2> b2 = {8.5, 22.5};
trainingSet.add(BIG, b1);
trainingSet.add(BIG, b2);
NaiveBayesClasifier<Bird, 2> clasifier;
EXPECT_TRUE(clasifier.train(trainingSet));
std::array<double, 2> sample1 = {1.5, 9};
std::array<double, 2> sample2 = {4.9, 16};
std::array<double, 2> sample3 = {9, 20};
EXPECT_EQ(clasifier.clasify(sample1), SMALL);
EXPECT_EQ(clasifier.clasify(sample2), MIDDLE);
EXPECT_EQ(clasifier.clasify(sample3), BIG);
}