-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
vw_arguments.h
139 lines (119 loc) · 2.79 KB
/
vw_arguments.h
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
Copyright (c) by respective owners including Yahoo!, Microsoft, and
individual contributors. All rights reserved. Released under a BSD (revised)
license as described in the file LICENSE.
*/
#pragma once
#include <msclr\marshal_cppstd.h>
#include "vw.h"
#include <algorithm>
using namespace std;
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
namespace VW
{
/// <summary>
/// command line arguments extracted from native C++.
/// </summary>
public ref class VowpalWabbitArguments
{
private:
initonly String^ m_data;
initonly String^ m_finalRegressor;
const bool m_testonly;
const int m_passes;
List<String^>^ m_regressors;
String^ m_commandLine;
int m_numberOfActions;
float m_learning_rate;
float m_power_t;
internal:
VowpalWabbitArguments(vw* vw) :
m_data(gcnew String(vw->data_filename.c_str())),
m_finalRegressor(gcnew String(vw->final_regressor_name.c_str())),
m_testonly(!vw->training),
m_passes((int)vw->numpasses)
{ po::variables_map& vm = vw->opts_n_args.vm;
if (vm.count("initial_regressor") || vm.count("i"))
{ m_regressors = gcnew List<String^>;
vector<string> regs = vm["initial_regressor"].as< vector<string> >();
for (auto& r : regs)
m_regressors->Add(gcnew String(r.c_str()));
}
StringBuilder^ sb = gcnew StringBuilder();
for (auto& s : vw->opts_n_args.args)
sb->AppendFormat("{0} ", gcnew String(s.c_str()));
m_commandLine = sb->ToString()->TrimEnd();
if (vw->opts_n_args.vm.count("cb"))
m_numberOfActions = (int)vw->opts_n_args.vm["cb"].as<uint32_t>();
m_learning_rate = vw->eta;
m_power_t = vw->power_t;
}
public:
/// <summary>
/// The input data file.
/// </summary>
property String^ Data
{ String^ get()
{ return m_data;
}
}
/// <summary>
/// True if "-t" for test only mode supplied as part of arguments.
/// </summary>
property bool TestOnly
{ bool get()
{ return m_testonly;
}
}
/// <summary>
/// Number of passes.
/// </summary>
property int NumPasses
{ int get()
{ return m_passes;
}
}
/// <summary>
/// The output model filename.
/// </summary>
property String^ FinalRegressor
{ String^ get()
{ return m_finalRegressor;
}
}
/// <summary>
///The list of input model filenames.
/// </summary>
property List<String^>^ InitialRegressors
{ List<String^>^ get()
{ return m_regressors;
}
}
property String^ CommandLine
{ String^ get()
{ return m_commandLine;
}
}
property int ContextualBanditNumberOfActions
{ int get()
{ return m_numberOfActions;
}
}
property float LearningRate
{
float get()
{
return m_learning_rate;
}
}
property float PowerT
{
float get()
{
return m_power_t;
}
}
};
}