forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathezexample_train.cc
71 lines (56 loc) · 1.36 KB
/
ezexample_train.cc
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include "../vowpalwabbit/parser.h"
#include "../vowpalwabbit/vw.h"
#include "../vowpalwabbit/ezexample.h"
using namespace std;
void run(vw*vw)
{ ezexample ex(vw, true); // we're doing csoaa_ldf so we need multiline examples
/// BEGIN FIRST MULTILINE EXAMPLE
ex(vw_namespace('s'))
("p^the_man")
("w^the")
("w^man")
(vw_namespace('t'))
("p^un_homme")
("w^un")
("w^homme");
ex.set_label("1:1");
ex.train();
--ex; // remove the most recent namespace
ex(vw_namespace('t'))
("p^le_homme")
("w^le")
("w^homme");
ex.set_label("2:0");
ex.train();
// push it through VW for training
ex.finish();
/// BEGIN SECOND MULTILINE EXAMPLE
ex(vw_namespace('s'))
("p^a_man")
("w^a")
("w^man")
(vw_namespace('t'))
("p^un_homme")
("w^un")
("w^homme");
ex.set_label("1:0");
ex.train();
--ex; // remove the most recent namespace
ex(vw_namespace('t'))
("p^le_homme")
("w^le")
("w^homme");
ex.set_label("2:1");
ex.train();
// push it through VW for training
ex.finish();
}
int main(int argc, char *argv[])
{ // INITIALIZE WITH WHATEVER YOU WOULD PUT ON THE VW COMMAND LINE -- THIS WILL STORE A MODEL TO train.ezw
vw* vw = VW::initialize("--hash all -q st --noconstant -f train.w --quiet --csoaa_ldf m");
run(vw);
// AND FINISH UP
cerr << "ezexample_train finish"<<endl;
VW::finish(*vw);
}