ml4r 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/ml4r/{LinearRegression.h → LinearRegression/LinearRegression.h} +25 -19
- data/ext/ml4r/LinearRegression/OLSLinearRegression.h +29 -0
- data/ext/ml4r/MachineLearning/DecisionTree/CategoryInfo.h +32 -0
- data/ext/ml4r/MachineLearning/DecisionTree/DecisionTreeExperiment.h +30 -0
- data/ext/ml4r/MachineLearning/DecisionTree/DecisionTreeNode.h +86 -0
- data/ext/ml4r/MachineLearning/DecisionTree/FeatureInteraction.h +31 -0
- data/ext/ml4r/MachineLearning/DecisionTree/NodeSplitter.h +45 -0
- data/ext/ml4r/MachineLearning/DecisionTree/NodeSplitterCategorical.h +17 -0
- data/ext/ml4r/MachineLearning/DecisionTree/NodeSplitterContinuous.h +16 -0
- data/ext/ml4r/MachineLearning/DecisionTree/SplitDefinition.h +81 -0
- data/ext/ml4r/MachineLearning/GBM/BernoulliCalculator.h +29 -0
- data/ext/ml4r/MachineLearning/GBM/GBM.h +50 -0
- data/ext/ml4r/MachineLearning/GBM/GBMCalculator.h +31 -0
- data/ext/ml4r/MachineLearning/GBM/GBMData.h +0 -0
- data/ext/ml4r/MachineLearning/GBM/GBMEstimator.h +79 -0
- data/ext/ml4r/MachineLearning/GBM/GBMOutput.h +53 -0
- data/ext/ml4r/MachineLearning/GBM/GBMParameters.h +50 -0
- data/ext/ml4r/MachineLearning/GBM/GBMRunner.h +35 -0
- data/ext/ml4r/MachineLearning/GBM/GaussianCalculator.h +29 -0
- data/ext/ml4r/MachineLearning/GBM/ZenithGBM.h +27 -0
- data/ext/ml4r/MachineLearning/MLData/MLData.h +77 -0
- data/ext/ml4r/MachineLearning/MLData/MLDataFields.h +25 -0
- data/ext/ml4r/MachineLearning/MLData/MLDataReader.h +37 -0
- data/ext/ml4r/MachineLearning/MLData/ZenithMLData.h +13 -0
- data/ext/ml4r/MachineLearning/MLData/ZenithMLDataReader.h +20 -0
- data/ext/ml4r/MachineLearning/MLEstimator.h +30 -0
- data/ext/ml4r/MachineLearning/MLEstimatorFactory.h +25 -0
- data/ext/ml4r/MachineLearning/MLExperiment.h +41 -0
- data/ext/ml4r/MachineLearning/MLOutput.h +45 -0
- data/ext/ml4r/MachineLearning/MLParameters.h +16 -0
- data/ext/ml4r/MachineLearning/MLRunner.h +47 -0
- data/ext/ml4r/MachineLearning/MLUtils.h +75 -0
- data/ext/ml4r/MachineLearning/RandomForest/RandomForestEstimator.h +47 -0
- data/ext/ml4r/MachineLearning/RandomForest/RandomForestOutput.h +33 -0
- data/ext/ml4r/MachineLearning/RandomForest/RandomForestParameters.h +32 -0
- data/ext/ml4r/MachineLearning/RandomForest/RandomForestRunner.h +34 -0
- data/ext/ml4r/extconf.rb +16 -3
- data/ext/ml4r/{MathUtils.h → utils/MathUtils.h} +0 -0
- data/ext/ml4r/{MatrixInversion.h → utils/MatrixInversion.h} +0 -0
- data/ext/ml4r/utils/StochasticUtils.h +33 -0
- data/ext/ml4r/utils/Utils.h +147 -0
- data/ext/ml4r/utils/VlcMessage.h +44 -0
- data/lib/ml4r/linear_regression.rb +7 -0
- metadata +45 -13
- data/ext/ml4r/LinearRegression/ZenithRegression.h +0 -17
- data/ext/ml4r/OLSLinearRegression.h +0 -23
- data/ext/ml4r/Utils.h +0 -53
- data/ext/ml4r/example.h +0 -18
- data/ext/ml4r/swig/example.h +0 -13
- data/ext/ml4r/swig/example_wrap.c +0 -2093
- data/ext/ml4r/utils/RubyUtils.h +0 -174
data/ext/ml4r/utils/RubyUtils.h
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
#ifndef RubyUtils_h__
|
2
|
-
#define RubyUtils_h__
|
3
|
-
|
4
|
-
#include <string>
|
5
|
-
#include <utility>
|
6
|
-
using std::pair;
|
7
|
-
using std::string;
|
8
|
-
|
9
|
-
namespace RubyUtils
|
10
|
-
{
|
11
|
-
//template<class T> inline VALUE toValue(const T& v);
|
12
|
-
//template<class T> inline VALUE toValue(const vector<T>& v);
|
13
|
-
// template<class T, class U> inline VALUE toValue(const vector<pair<T,U>>& v);
|
14
|
-
//template<class T, class U, class V> inline VALUE toValue(const map<pair<T,U>,V>& v);
|
15
|
-
//template<class T, class U> inline VALUE toValue(const map<T,U>& v);
|
16
|
-
//template<class T, class U> inline VALUE toValue(const pair<T,U>& v);
|
17
|
-
inline VALUE toValue(const char* v) { return otRuby->ToNum(v); }
|
18
|
-
|
19
|
-
//template<class T> inline T fromValue(VALUE v);
|
20
|
-
//template<class T> inline void fromValue(VALUE v, T& t);
|
21
|
-
//template<class T, class U> inline void fromValue(VALUE v, pair<T,U>& t);
|
22
|
-
//template<class T> inline void fromValue(VALUE v, vector<T>& t);
|
23
|
-
};
|
24
|
-
|
25
|
-
template<> inline VALUE RubyUtils::toValue(const int& v)
|
26
|
-
{
|
27
|
-
return otRuby->ToNum(v);
|
28
|
-
}
|
29
|
-
|
30
|
-
template<> inline VALUE RubyUtils::toValue(const float& v)
|
31
|
-
{
|
32
|
-
return otRuby->ToNum(v);
|
33
|
-
}
|
34
|
-
|
35
|
-
template<> inline VALUE RubyUtils::toValue(const double& v)
|
36
|
-
{
|
37
|
-
return otRuby->ToNum(v);
|
38
|
-
}
|
39
|
-
|
40
|
-
template<> inline VALUE RubyUtils::toValue(const string& v)
|
41
|
-
{
|
42
|
-
return otRuby->ToNum(v.c_str());
|
43
|
-
}
|
44
|
-
|
45
|
-
template<> inline VALUE RubyUtils::toValue(const VALUE& v)
|
46
|
-
{
|
47
|
-
return v;
|
48
|
-
}
|
49
|
-
|
50
|
-
template<class T> inline VALUE RubyUtils::toValue(const vector<T>& v)
|
51
|
-
{
|
52
|
-
VALUE returnValue = otRuby->rb_ary_new();
|
53
|
-
BOOST_FOREACH(const T& val, v)
|
54
|
-
otRuby->rb_ary_push(returnValue, toValue(val));
|
55
|
-
return returnValue;
|
56
|
-
}
|
57
|
-
|
58
|
-
template<class T, class U> inline VALUE RubyUtils::toValue(const pair<T,U>& v)
|
59
|
-
{
|
60
|
-
VALUE returnValue = otRuby->rb_ary_new();
|
61
|
-
otRuby->rb_ary_push(returnValue, toValue(v.first));
|
62
|
-
otRuby->rb_ary_push(returnValue, toValue(v.second));
|
63
|
-
return returnValue;
|
64
|
-
}
|
65
|
-
|
66
|
-
|
67
|
-
template<class T, class U> inline VALUE RubyUtils::toValue(const map<T,U>& v)
|
68
|
-
{
|
69
|
-
VALUE returnValue = otRuby->rb_hash_new();
|
70
|
-
BOOST_FOREACH(auto& keyValue, v)
|
71
|
-
{
|
72
|
-
otRuby->rb_hash_aset(returnValue, toValue(keyValue.first), toValue(keyValue.second));
|
73
|
-
}
|
74
|
-
return returnValue;
|
75
|
-
}
|
76
|
-
|
77
|
-
//////////////////////////////////////////////////////////////////////////
|
78
|
-
// FROM VALUE
|
79
|
-
//////////////////////////////////////////////////////////////////////////
|
80
|
-
|
81
|
-
template<class T> inline T RubyUtils::fromValue(VALUE v)
|
82
|
-
{
|
83
|
-
T t;
|
84
|
-
fromValue(v,t);
|
85
|
-
return t;
|
86
|
-
}
|
87
|
-
|
88
|
-
//////////////////////////////////////////////////////////////////////////
|
89
|
-
// FROM VALUE Two argument
|
90
|
-
//////////////////////////////////////////////////////////////////////////
|
91
|
-
|
92
|
-
template<> inline void RubyUtils::fromValue(VALUE v, int& i)
|
93
|
-
{
|
94
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_FIXNUM);
|
95
|
-
i = otRuby->AsLong(v);
|
96
|
-
}
|
97
|
-
|
98
|
-
template<> inline void RubyUtils::fromValue(VALUE v, double& d)
|
99
|
-
{
|
100
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_FLOAT);
|
101
|
-
d = otRuby->AsDouble(v);
|
102
|
-
}
|
103
|
-
|
104
|
-
template<> inline void RubyUtils::fromValue(VALUE v, float& f)
|
105
|
-
{
|
106
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_FLOAT);
|
107
|
-
f = (float) otRuby->AsDouble(v);
|
108
|
-
}
|
109
|
-
|
110
|
-
template<> inline void RubyUtils::fromValue(VALUE v, string& s)
|
111
|
-
{
|
112
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_STRING);
|
113
|
-
s = otRuby->AsString(v);
|
114
|
-
}
|
115
|
-
|
116
|
-
template<> inline void RubyUtils::fromValue(VALUE v, bool& b)
|
117
|
-
{
|
118
|
-
if (otRuby->rb_obj_is_kind_of(v, otRuby->rb_cTrueClass()))
|
119
|
-
b = true;
|
120
|
-
else if (otRuby->rb_obj_is_kind_of(v, otRuby->rb_cFalseClass()))
|
121
|
-
b = false;
|
122
|
-
else
|
123
|
-
{
|
124
|
-
otRuby->rb_raise(otRuby->rb_eRuntimeError(), "VALUE is not of type bool");
|
125
|
-
}
|
126
|
-
|
127
|
-
}
|
128
|
-
template<> inline void RubyUtils::fromValue(VALUE v, TOtSimpleVariable& sv)
|
129
|
-
{
|
130
|
-
if (otRuby->rb_obj_is_kind_of(v, otRuby->rb_cString()))
|
131
|
-
sv = TOtSimpleVariable(fromValue<string>(v));
|
132
|
-
else if (otRuby->rb_obj_is_instance_of(v, otRuby->rb_cFixnum()))
|
133
|
-
sv = TOtSimpleVariable(fromValue<int>(v));
|
134
|
-
else if (otRuby->rb_obj_is_instance_of(v, otRuby->rb_cFloat()))
|
135
|
-
sv = TOtSimpleVariable(fromValue<float>(v));
|
136
|
-
else
|
137
|
-
{
|
138
|
-
otRuby->rb_raise(otRuby->rb_eRuntimeError(), "Unknown VALUE type");
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
|
143
|
-
template<> inline void RubyUtils::fromValue(VALUE v, TOtMatrix& f)
|
144
|
-
{
|
145
|
-
//otRuby->rb_check_type(v, TOtRubyInterface::T_FLOAT);
|
146
|
-
if (!otRuby->rb_obj_is_kind_of(v, rb_cMatrix))
|
147
|
-
{
|
148
|
-
throw std::invalid_argument("[RubyUtils::fromValue] expected a matrix");
|
149
|
-
}
|
150
|
-
Gclib::TGcMatrix *m = (Gclib::TGcMatrix*)otRuby->GetDataPtr(v);
|
151
|
-
f.Connect(m);
|
152
|
-
}
|
153
|
-
|
154
|
-
template<class T, class U> inline void RubyUtils::fromValue(unsigned long v, pair<T,U> &returnValue)
|
155
|
-
{
|
156
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_ARRAY);
|
157
|
-
VALUE* v_array = otRuby->ToArray(v);
|
158
|
-
int length = otRuby->ArrayLen(v);
|
159
|
-
if (length != 2) throw runtime_error("Expected a pair, got an array with length " + ToString(length));
|
160
|
-
fromValue(v_array[0], returnValue.first);
|
161
|
-
fromValue(v_array[1], returnValue.second);
|
162
|
-
}
|
163
|
-
|
164
|
-
template<class T> inline void RubyUtils::fromValue(VALUE v, vector<T>& returnValue)
|
165
|
-
{
|
166
|
-
otRuby->rb_check_type(v, TOtRubyInterface::T_ARRAY);
|
167
|
-
VALUE* v_array = otRuby->ToArray(v);
|
168
|
-
int length = otRuby->ArrayLen(v);
|
169
|
-
returnValue.resize(length);
|
170
|
-
for (int i = 0; i < length; ++i)
|
171
|
-
fromValue(v_array[i], returnValue.at(i));
|
172
|
-
}
|
173
|
-
|
174
|
-
#endif // RubyUtils_h__
|