Vita
model_metric.cc
Go to the documentation of this file.
1
14
15namespace vita
16{
17
24 const dataframe &d) const
25{
26 Expects(!d.classes());
27 Expects(d.begin() != d.end());
28
29 std::uintmax_t ok(0), total_nr(0);
30
31 for (const auto &example : d)
32 {
33 if (const auto res = (*l)(example);
34 has_value(res) && issmall(lexical_cast<D_DOUBLE>(res)
35 - label_as<D_DOUBLE>(example)))
36 ++ok;
37
38 ++total_nr;
39 }
40
41 Ensures(total_nr);
42 return static_cast<double>(ok) / static_cast<double>(total_nr);
43}
44
51 const dataframe &d) const
52{
53 Expects(d.classes());
54 Expects(d.begin() != d.end());
55
56 std::uintmax_t ok(0), total_nr(0);
57
58 for (const auto &example : d)
59 {
60 if (l->tag(example).label == label(example))
61 ++ok;
62
63 ++total_nr;
64 }
65
66 Ensures(total_nr);
67 return static_cast<double>(ok) / static_cast<double>(total_nr);
68}
69
70} // namespace vita
double operator()(const core_reg_lambda_f *, const dataframe &) const override
Definition: model_metric.cc:23
The model_metric class choose the appropriate method considering this type.
Definition: lambda_f.h:181
The model_metric class choose the appropriate method considering this type.
Definition: lambda_f.h:116
A 2-dimensional labeled data structure with columns of potentially different types.
Definition: dataframe.h:48
iterator begin()
Definition: dataframe.cc:235
class_t classes() const
Definition: dataframe.cc:308
iterator end()
Definition: dataframe.cc:251
The main namespace for the project.
bool has_value(const value_t &v)
Definition: value.h:51
class_t label(const dataframe::example &e)
Gets the class_t ID (aka label) for a given example.
Definition: dataframe.h:231