blob: 8024cafe8445fcf024cb43ce91fc994f77b72700 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "vw.h"
#include "parse_args.h"
using namespace LEARNER;
namespace Scorer {
struct scorer{
vw* all;
};
template <bool is_learn>
void predict_or_learn(scorer& s, learner& base, example& ec)
{
label_data* ld = (label_data*)ec.ld;
s.all->set_minmax(s.all->sd, ld->label);
if (is_learn)
base.learn(ec);
else
base.predict(ec);
}
learner* setup(vw& all, std::vector<std::string>&opts, po::variables_map& vm, po::variables_map& vm_file)
{
scorer* s = (scorer*)calloc(1, sizeof(scorer));
s->all = &all;
learner* l = new learner(s, all.l);
l->set_learn<scorer, predict_or_learn<true> >();
l->set_predict<scorer, predict_or_learn<false> >();
return l;
}
}
|