bindings_docstring_keyed.cpp 28.4 KB
Newer Older
1
2
3
4
5
6
7
#include <python/bindings.hpp>

using namespace boost::python;

void sisso::register_all()
{
    sisso::descriptor_identifier::registerModel();
8
    sisso::descriptor_identifier::registerModelRegressor();
9
    sisso::descriptor_identifier::registerModelLogRegressor();
10
    sisso::descriptor_identifier::registerModelClassifier();
11
    sisso::descriptor_identifier::registerSISSO_DI();
12
    sisso::descriptor_identifier::registerSISSORegressor();
13
    sisso::descriptor_identifier::registerSISSOLogRegressor();
14
    sisso::descriptor_identifier::registerSISSOClassifier();
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    sisso::feature_creation::registerFeatureSpace();
    sisso::feature_creation::registerUnit();
    sisso::feature_creation::node::registerNode();
    sisso::feature_creation::node::registerFeatureNode();
    sisso::feature_creation::node::registerModelNode();
    sisso::feature_creation::node::registerOperatorNode<1>();
    sisso::feature_creation::node::registerOperatorNode<2>();
    sisso::feature_creation::node::registerAddNode();
    sisso::feature_creation::node::registerSubNode();
    sisso::feature_creation::node::registerDivNode();
    sisso::feature_creation::node::registerMultNode();
    sisso::feature_creation::node::registerAbsDiffNode();
    sisso::feature_creation::node::registerAbsNode();
    sisso::feature_creation::node::registerInvNode();
    sisso::feature_creation::node::registerLogNode();
    sisso::feature_creation::node::registerExpNode();
    sisso::feature_creation::node::registerNegExpNode();
    sisso::feature_creation::node::registerSinNode();
    sisso::feature_creation::node::registerCosNode();
    sisso::feature_creation::node::registerCbNode();
    sisso::feature_creation::node::registerCbrtNode();
    sisso::feature_creation::node::registerSqNode();
    sisso::feature_creation::node::registerSqrtNode();
    sisso::feature_creation::node::registerSixPowNode();
39

40
    void (*init_val_ar)(int, int, int, int) = &node_value_arrs::initialize_values_arr;
Thomas Purcell's avatar
Thomas Purcell committed
41

42
    def("phi_selected_from_file", &str2node::phi_selected_from_file_py);
Thomas Purcell's avatar
Thomas Purcell committed
43
    def("initialize_values_arr", init_val_ar);
44
    def("initialize_d_matrix_arr", &node_value_arrs::initialize_d_matrix_arr);
45
46
47
48
49
50
51
}

void sisso::feature_creation::registerFeatureSpace()
{
    void (FeatureSpace::*sis_list)(list) = &FeatureSpace::sis;
    void (FeatureSpace::*sis_ndarray)(np::ndarray) = &FeatureSpace::sis;

52
53
54
    class_<FeatureSpace>("FeatureSpace", init<list, list, np::ndarray, list, optional<std::string, int, int, int, int, double, double, double>>())
        .def(init<list, list, list, list, optional<std::string, int, int, int, int, double, double, double>>())
        .def(init<std::string, list, list, optional<std::string, int, double>>())
55
56
57
        .def("sis", sis_list, "@DocString_feat_space_sis_list@")
        .def("sis", sis_ndarray, "@DocString_feat_space_sis_arr@")
        .def("feat_in_phi", &FeatureSpace::feat_in_phi, "@DocString_feat_space_feat_in_phi@")
58
59
        .def("remove_feature", &FeatureSpace::remove_feature, "@DocString_feat_space_remove_feature@")
        .def("get_feature", &FeatureSpace::get_feature, "@DocString_feat_space_get_feature@")
60
61
        .add_property("phi_selected", &FeatureSpace::phi_selected_py, "@DocString_feat_space_phi_selected_py@")
        .add_property("phi0", &FeatureSpace::phi0_py, "@DocString_feat_space_phi0_py@")
62
        .add_property("phi", &FeatureSpace::phi_py, "@DocString_feat_space_phi_py@")
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
        .add_property("scores", &FeatureSpace::scores_py, "@DocString_feat_space_scores_py@")
        .add_property("task_sizes", &FeatureSpace::task_sizes_py, "@DocString_feat_space_task_sizes_py@")
        .add_property("allowed_ops", &FeatureSpace::allowed_ops_py, "@DocString_feat_space_allowed_ops_py@")
        .add_property("start_gen", &FeatureSpace::start_gen_py, "@DocString_feat_space_start_gen_py@")
        .add_property("feature_space_file", &FeatureSpace::feature_space_file, "@DocString_feat_space_feature_space_file@")
        .add_property("l_bound", &FeatureSpace::l_bound, "@DocString_feat_space_l_bound@")
        .add_property("u_bound", &FeatureSpace::u_bound, "@DocString_feat_space_u_bound@")
        .add_property("max_phi", &FeatureSpace::max_phi, "@DocString_feat_space_max_phi@")
        .add_property("n_sis_select", &FeatureSpace::n_sis_select, "@DocString_feat_space_n_sis_select@")
        .add_property("n_samp", &FeatureSpace::n_samp, "@DocString_feat_space_n_samp@")
        .add_property("n_feat", &FeatureSpace::n_feat, "@DocString_feat_space_n_feat@")
        .add_property("n_rung_store", &FeatureSpace::n_rung_store, "@DocString_feat_space_n_rung_store@")
        .add_property("n_rung_generate", &FeatureSpace::n_rung_generate, "@DocString_feat_space_n_rung_generate@")
    ;
}

void sisso::feature_creation::registerUnit()
{
    class_<Unit>("Unit", init<>())
        .def(init<std::map<std::string, double>>())
        .def(init<std::string>())
        .def(init<Unit&>())
        .def("__str__", &Unit::toString, "@DocString_unit_str@")
        .def("__repr__", &Unit::toString, "@DocString_unit_str@")
        .def("inverse", &Unit::inverse, "@DocString_unit_inverse@")
        .def(self * self)
        .def(self / self)
        .def(self *= self)
        .def(self /= self)
        .def(self == self)
        .def(self != self)
        .def("__pow__", &Unit::operator^, "@DocString_unit_pow@")
95
        .add_property("latex_str", &Unit::toLatexString, "@DocString_unit_latex_str@")
96
97
98
99
100
    ;
}

void sisso::feature_creation::node::registerNode()
{
101
102
    void (Node::*reindex_1)(unsigned long int) = &Node::reindex;
    void (Node::*reindex_2)(unsigned long int, unsigned long int) = &Node::reindex;
103

104
105
106
107
108
109
110
111
112
113
114
115
116
    class_<sisso::feature_creation::node::NodeWrap, boost::noncopyable>("Node", no_init)
        .def("reindex", reindex_1, "@DocString_node_reindex_1@")
        .def("reindex", reindex_2, "@DocString_node_reindex_2@")
        .def("__str__", &Node::expr, "@DocString_node_expr@")
        .def("__repr__", &Node::expr, "@DocString_node_expr@")
        .add_property("n_samp", &Node::n_samp, "@DocString_node_n_samp@")
        .add_property("n_test_samp", &Node::n_test_samp, "@DocString_node_n_test_samp@")
        .add_property("feat_ind", &Node::feat_ind, "@DocString_node_feat_ind@")
        .add_property("arr_ind", &Node::arr_ind, "@DocString_node_arr_ind@")
        .add_property("selected", &Node::selected, &Node::set_selected, "@DocString_node_set_selected@")
        .add_property("d_mat_ind", &Node::d_mat_ind, &Node::set_d_mat_ind, "@DocString_node_set_d_mat_ind@")
        .add_property("value", &Node::value_py, "@DocString_node_value_py@")
        .add_property("test_value", &Node::test_value_py, "@DocString_node_test_value_py@")
117
118
        .add_property("primary_feat_decomp", &Node::primary_feature_decomp_py, "@DocString_node_primary_feature_decomp@")
        .add_property("postfix_expr", &Node::postfix_expr, "@DocString_node_postfix_expr@")
119
        .add_property("latex_expr", &Node::latex_expr, "@DocString_node_latex_expr@")
120
121
122
123
124
125
126
        .def("expr", pure_virtual(&Node::expr), "@DocString_node_expr@")
        .def("unit", pure_virtual(&Node::unit), "@DocString_node_unit@")
        .def("set_value", pure_virtual(&Node::set_value), "@DocString_node_set_value@")
        .def("set_test_value", pure_virtual(&Node::set_test_value), "@DocString_node_set_test_value@")
        .def("is_nan", pure_virtual(&Node::is_nan), "@DocString_node_is_nan@")
        .def("is_const", pure_virtual(&Node::is_const), "@DocString_node_is_const@")
        .def("rung", pure_virtual(&Node::rung), "@DocString_node_rung@")
Thomas Purcell's avatar
Bug Fix    
Thomas Purcell committed
127
128
        .def("n_feats", pure_virtual(&Node::n_feats), "@DocString_node_n_feats@")
        .def("feat", pure_virtual(&Node::feat), "@DocString_node_feat@")
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    ;
}

void sisso::feature_creation::node::registerFeatureNode()
{
    std::string (FeatureNode::*expr_1)() = &FeatureNode::expr;
    std::string (FeatureNode::*expr_const)() const = &FeatureNode::expr;

    using namespace boost::python;
    class_<FeatureNode, bases<Node>>("FeatureNode", init<int, std::string, np::ndarray, np::ndarray, Unit>())
        .def(init<int, std::string, py::list, py::list, Unit>())
        .def("is_nan", &FeatureNode::is_nan, "@DocString_feat_node_is_nan@")
        .def("is_const", &FeatureNode::is_const, "@DocString_feat_node_is_const@")
        .def("set_value", &FeatureNode::set_value, "@DocString_feat_node_set_value@")
        .def("set_test_value", &FeatureNode::set_test_value, "@DocString_feat_node_set_test_value@")
        .add_property("expr", expr_1, "@DocString_feat_node_expr_1@")
        .add_property("expr", expr_const, "@DocString_feat_node_expr_const@")
        .add_property("unit", &FeatureNode::unit, "@DocString_feat_node_unit@")
        .add_property("rung", &FeatureNode::rung, "@DocString_feat_node_rung@")
    ;
}

void sisso::feature_creation::node::registerModelNode()
{
    std::string (ModelNode::*expr_1)() = &ModelNode::expr;
    std::string (ModelNode::*expr_const)() const = &ModelNode::expr;

    using namespace boost::python;
157
    class_<ModelNode, bases<FeatureNode>>("ModelNode", init<int, int, std::string, std::string, std::string, std::vector<double>, std::vector<double>, Unit>())
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
        .def("is_nan", &ModelNode::is_nan, "@DocString_model_node_is_nan@")
        .def("is_const", &ModelNode::is_const, "@DocString_model_node_is_const@")
        .def("set_value", &ModelNode::set_value, "@DocString_model_node_set_value@")
        .def("set_test_value", &ModelNode::set_test_value, "@DocString_model_node_set_test_value@")
        .add_property("rung", &ModelNode::rung, "@DocString_model_node_rung@")
    ;
}

void sisso::feature_creation::node::registerAddNode()
{
    class_<AddNode, bases<OperatorNode<2>>>("AddNode", init<node_ptr, node_ptr, int, double, double>())
        .def("set_value", &AddNode::set_value, "@DocString_add_node_set_value@")
        .def("set_test_value", &AddNode::set_test_value, "@DocString_add_node_set_test_value@")
        .add_property("expr", &AddNode::expr, "@DocString_add_node_expr@")
        .add_property("unit", &AddNode::unit, "@DocString_add_node_unit@")
        .add_property("rung", &AddNode::rung, "@DocString_add_node_rung@")
    ;
}

void sisso::feature_creation::node::registerSubNode()
{
    class_<SubNode, bases<OperatorNode<2>>>("SubNode", init<node_ptr, node_ptr, int, double, double>())
        .def("set_value", &SubNode::set_value, "@DocString_sub_node_set_value@")
        .def("set_test_value", &SubNode::set_test_value, "@DocString_sub_node_set_test_value@")
        .add_property("expr", &SubNode::expr, "@DocString_sub_node_expr@")
        .add_property("unit", &SubNode::unit, "@DocString_sub_node_unit@")
        .add_property("rung", &SubNode::rung, "@DocString_sub_node_rung@")
    ;
}

void sisso::feature_creation::node::registerDivNode()
{
    class_<DivNode, bases<OperatorNode<2>>>("DivNode", init<node_ptr, node_ptr, int, double, double>())
        .def("set_value", &DivNode::set_value, "@DocString_div_node_set_value@")
        .def("set_test_value", &DivNode::set_test_value, "@DocString_div_node_set_test_value@")
        .add_property("expr", &DivNode::expr, "@DocString_div_node_expr@")
        .add_property("unit", &DivNode::unit, "@DocString_div_node_unit@")
        .add_property("rung", &DivNode::rung, "@DocString_div_node_rung@")
    ;
}

void sisso::feature_creation::node::registerMultNode()
{
    class_<MultNode, bases<OperatorNode<2>>>("MultNode", init<node_ptr, node_ptr, int, double, double>())
        .def("set_value", &MultNode::set_value, "@DocString_mult_node_set_value@")
        .def("set_test_value", &MultNode::set_test_value, "@DocString_mult_node_set_test_value@")
        .add_property("expr", &MultNode::expr, "@DocString_mult_node_expr@")
        .add_property("unit", &MultNode::unit, "@DocString_mult_node_unit@")
        .add_property("rung", &MultNode::rung, "@DocString_mult_node_rung@")
    ;
}

void sisso::feature_creation::node::registerAbsDiffNode()
{
    class_<AbsDiffNode, bases<OperatorNode<2>>>("AbsDiffNode", init<node_ptr, node_ptr, int, double, double>())
        .def("set_value", &AbsDiffNode::set_value, "@DocString_abs_diff_node_set_value@")
        .def("set_test_value", &AbsDiffNode::set_test_value, "@DocString_abs_diff_node_set_test_value@")
        .add_property("expr", &AbsDiffNode::expr, "@DocString_abs_diff_node_expr@")
        .add_property("unit", &AbsDiffNode::unit, "@DocString_abs_diff_node_unit@")
        .add_property("rung", &AbsDiffNode::rung, "@DocString_abs_diff_node_rung@")
    ;
}

void sisso::feature_creation::node::registerAbsNode()
{
    class_<AbsNode, bases<OperatorNode<1>>>("AbsNode", init<node_ptr, int, double, double>())
        .def("set_value", &AbsNode::set_value, "@DocString_abs_node_set_value@")
        .def("set_test_value", &AbsNode::set_test_value, "@DocString_abs_node_set_test_value@")
        .add_property("expr", &AbsNode::expr, "@DocString_abs_node_expr@")
        .add_property("unit", &AbsNode::unit, "@DocString_abs_node_unit@")
        .add_property("rung", &AbsNode::rung, "@DocString_abs_node_rung@")
    ;
}

void sisso::feature_creation::node::registerInvNode()
{
    class_<InvNode, bases<OperatorNode<1>>>("InvNode", init<node_ptr, int, double, double>())
        .def("set_value", &InvNode::set_value, "@DocString_inv_node_set_value@")
        .def("set_test_value", &InvNode::set_test_value, "@DocString_inv_node_set_test_value@")
        .add_property("expr", &InvNode::expr, "@DocString_inv_node_expr@")
        .add_property("unit", &InvNode::unit, "@DocString_inv_node_unit@")
        .add_property("rung", &InvNode::rung, "@DocString_inv_node_rung@")
    ;
}

void sisso::feature_creation::node::registerLogNode()
{
    class_<LogNode, bases<OperatorNode<1>>>("LogNode", init<node_ptr, int, double, double>())
        .def("set_value", &LogNode::set_value, "@DocString_log_node_set_value@")
        .def("set_test_value", &LogNode::set_test_value, "@DocString_log_node_set_test_value@")
        .add_property("expr", &LogNode::expr, "@DocString_log_node_expr@")
        .add_property("unit", &LogNode::unit, "@DocString_log_node_unit@")
        .add_property("rung", &LogNode::rung, "@DocString_log_node_rung@")
    ;
}

void sisso::feature_creation::node::registerExpNode()
{
    class_<ExpNode, bases<OperatorNode<1>>>("ExpNode", init<node_ptr, int, double, double>())
        .def("set_value", &ExpNode::set_value, "@DocString_exp_node_set_value@")
        .def("set_test_value", &ExpNode::set_test_value, "@DocString_exp_node_set_test_value@")
        .add_property("expr", &ExpNode::expr, "@DocString_exp_node_expr@")
        .add_property("unit", &ExpNode::unit, "@DocString_exp_node_unit@")
        .add_property("rung", &ExpNode::rung, "@DocString_exp_node_rung@")
    ;
}

void sisso::feature_creation::node::registerNegExpNode()
{
    class_<NegExpNode, bases<OperatorNode<1>>>("NegExpNode", init<node_ptr, int, double, double>())
        .def("set_value", &NegExpNode::set_value, "@DocString_neg_exp_node_set_value@")
        .def("set_test_value", &NegExpNode::set_test_value, "@DocString_neg_exp_node_set_test_value@")
        .add_property("expr", &NegExpNode::expr, "@DocString_neg_exp_node_expr@")
        .add_property("unit", &NegExpNode::unit, "@DocString_neg_exp_node_unit@")
        .add_property("rung", &NegExpNode::rung, "@DocString_neg_exp_node_rung@")
    ;
}

void sisso::feature_creation::node::registerSinNode()
{
    class_<SinNode, bases<OperatorNode<1>>>("SinNode", init<node_ptr, int, double, double>())
        .def("set_value", &SinNode::set_value, "@DocString_sin_node_set_value@")
        .def("set_test_value", &SinNode::set_test_value, "@DocString_sin_node_set_test_value@")
        .add_property("expr", &SinNode::expr, "@DocString_sin_node_expr@")
        .add_property("unit", &SinNode::unit, "@DocString_sin_node_unit@")
        .add_property("rung", &SinNode::rung, "@DocString_sin_node_rung@")
    ;
}

void sisso::feature_creation::node::registerCosNode()
{
    class_<CosNode, bases<OperatorNode<1>>>("CosNode", init<node_ptr, int, double, double>())
        .def("set_value", &CosNode::set_value, "@DocString_cos_node_set_value@")
        .def("set_test_value", &CosNode::set_test_value, "@DocString_cos_node_set_test_value@")
        .add_property("expr", &CosNode::expr, "@DocString_cos_node_expr@")
        .add_property("unit", &CosNode::unit, "@DocString_cos_node_unit@")
        .add_property("rung", &CosNode::rung, "@DocString_cos_node_rung@")
    ;
}

void sisso::feature_creation::node::registerCbNode()
{
    class_<CbNode, bases<OperatorNode<1>>>("CbNode", init<node_ptr, int, double, double>())
        .def("set_value", &CbNode::set_value, "@DocString_cb_node_set_value@")
        .def("set_test_value", &CbNode::set_test_value, "@DocString_cb_node_set_test_value@")
        .add_property("expr", &CbNode::expr, "@DocString_cb_node_expr@")
        .add_property("unit", &CbNode::unit, "@DocString_cb_node_unit@")
        .add_property("rung", &CbNode::rung, "@DocString_cb_node_rung@")
    ;
}

void sisso::feature_creation::node::registerCbrtNode()
{
    class_<CbrtNode, bases<OperatorNode<1>>>("CbrtNode", init<node_ptr, int, double, double>())
        .def("set_value", &CbrtNode::set_value, "@DocString_cbrt_node_set_value@")
        .def("set_test_value", &CbrtNode::set_test_value, "@DocString_cbrt_node_set_test_value@")
        .add_property("expr", &CbrtNode::expr, "@DocString_cbrt_node_expr@")
        .add_property("unit", &CbrtNode::unit, "@DocString_cbrt_node_unit@")
        .add_property("rung", &CbrtNode::rung, "@DocString_cbrt_node_rung@")
    ;
}

void sisso::feature_creation::node::registerSqNode()
{
    class_<SqNode, bases<OperatorNode<1>>>("SqNode", init<node_ptr, int, double, double>())
        .def("set_value", &SqNode::set_value, "@DocString_sq_node_set_value@")
        .def("set_test_value", &SqNode::set_test_value, "@DocString_sq_node_set_test_value@")
        .add_property("expr", &SqNode::expr, "@DocString_sq_node_expr@")
        .add_property("unit", &SqNode::unit, "@DocString_sq_node_unit@")
        .add_property("rung", &SqNode::rung, "@DocString_sq_node_rung@")
    ;
}

void sisso::feature_creation::node::registerSqrtNode()
{
    class_<SqrtNode, bases<OperatorNode<1>>>("SqrtNode", init<node_ptr, int, double, double>())
        .def("set_value", &SqrtNode::set_value, "@DocString_sqrt_node_set_value@")
        .def("set_test_value", &SqrtNode::set_test_value, "@DocString_sqrt_node_set_test_value@")
        .add_property("expr", &SqrtNode::expr, "@DocString_sqrt_node_expr@")
        .add_property("unit", &SqrtNode::unit, "@DocString_sqrt_node_unit@")
        .add_property("rung", &SqrtNode::rung, "@DocString_sqrt_node_rung@")
    ;
}

void sisso::feature_creation::node::registerSixPowNode()
{
    class_<SixPowNode, bases<OperatorNode<1>>>("SixPowNode", init<node_ptr, int, double, double>())
        .def("set_value", &SixPowNode::set_value, "@DocString_six_pow_node_set_value@")
        .def("set_test_value", &SixPowNode::set_test_value, "@DocString_six_pow_node_set_test_value@")
        .add_property("expr", &SixPowNode::expr, "@DocString_six_pow_node_expr@")
        .add_property("unit", &SixPowNode::unit, "@DocString_six_pow_node_unit@")
        .add_property("rung", &SixPowNode::rung, "@DocString_six_pow_node_rung@")
    ;
}

void sisso::descriptor_identifier::registerModel()
{
355
    class_<sisso::descriptor_identifier::Model_Wrap, boost::noncopyable>("Model", no_init)
356
357
358
359
360
361
        .add_property("n_samp_train", &Model::n_samp_train, "@DocString_model_n_samp_train@")
        .add_property("n_samp_test", &Model::n_samp_test, "@DocString_model_n_samp_test@")
        .add_property("n_dim", &Model::n_dim, "@DocString_model_n_dim@")
        .add_property("prop_train", &Model::prop_train, "@DocString_model_prop_train@")
        .add_property("prop_test", &Model::prop_test, "@DocString_model_prop_test@")
        .add_property("feats", &Model::feats, "@DocString_model_feats@")
362
        .add_property("coefs", &Model::coefs_py, "@DocString_model_coefs@")
363
        .add_property("prop_unit", &Model::prop_unit, "@DocString_model_prop_unit@")
364
        .add_property("prop_label", &Model::prop_label, "@DocString_model_prop_label@")
Thomas Purcell's avatar
Thomas Purcell committed
365
366
367
        .add_property("task_size_train", &Model::task_sizes_train, "@DocString_model_task_sizes_train")
        .add_property("task_size_test", &Model::task_sizes_test, "@DocString_model_task_sizes_test")
        .add_property("fix_intercept", &Model::fix_intercept, "@DocString_model_fix_intercept")
368
    ;
369
370
}

371
372
void sisso::descriptor_identifier::registerModelRegressor()
{
373
    class_<ModelRegressor, bases<Model>>("ModelRegressor", init<std::string, Unit, std::vector<double>, std::vector<double>, std::vector<model_node_ptr>, std::vector<int>, std::vector<int>, bool>())
374
375
376
377
        .def(init<std::string>())
        .def(init<std::string, std::string>())
        .def("__str__", &ModelRegressor::toString, "@DocString_model_reg_str@")
        .def("__repr__", &ModelRegressor::toString, "@DocString_model_reg_str@")
378
        .add_property("latex_str", &ModelRegressor::toLatexString, "@DocString_model_reg_latex_str@")
379
380
381
382
        .add_property("fit", &ModelRegressor::prop_train_est, "@DocString_model_reg_prop_train_est@")
        .add_property("predict", &ModelRegressor::prop_test_est, "@DocString_model_reg_prop_test_est@")
        .add_property("train_error", &ModelRegressor::train_error, "@DocString_model_reg_train_error@")
        .add_property("test_error", &ModelRegressor::test_error, "@DocString_model_reg_test_error@")
383
384
        .add_property("r2", &ModelRegressor::r2, "@DocString_model_reg_r2@")
        .add_property("test_r2", &ModelRegressor::test_r2, "@DocString_model_reg_test_r2@")
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
        .add_property("rmse", &ModelRegressor::rmse, "@DocString_model_reg_rmse@")
        .add_property("test_rmse", &ModelRegressor::test_rmse, "@DocString_model_reg_test_rmse@")
        .add_property("max_ae", &ModelRegressor::max_ae, "@DocString_model_reg_max_ae@")
        .add_property("test_max_ae", &ModelRegressor::test_max_ae, "@DocString_model_reg_test_max_ae@")
        .add_property("mae", &ModelRegressor::mae, "@DocString_model_reg_mae@")
        .add_property("test_mae", &ModelRegressor::test_mae, "@DocString_model_reg_test_mae@")
        .add_property("mape", &ModelRegressor::mape, "@DocString_model_reg_mape@")
        .add_property("test_mape", &ModelRegressor::test_mape, "@DocString_model_reg_test_mape@")
        .add_property("percentile_25_ae", &ModelRegressor::percentile_25_ae, "@DocString_model_reg_percentile_25_ae@")
        .add_property("percentile_25_test_ae", &ModelRegressor::percentile_25_test_ae, "@DocString_model_reg_test_percentile_25_test_ae@")
        .add_property("percentile_50_ae", &ModelRegressor::percentile_50_ae, "@DocString_model_reg_percentile_50_ae@")
        .add_property("percentile_50_test_ae", &ModelRegressor::percentile_50_test_ae, "@DocString_model_reg_test_percentile_50_test_ae@")
        .add_property("percentile_75_ae", &ModelRegressor::percentile_75_ae, "@DocString_model_reg_percentile_75_ae@")
        .add_property("percentile_75_test_ae", &ModelRegressor::percentile_75_test_ae, "@DocString_model_reg_test_percentile_75_test_ae@")
        .add_property("percentile_95_ae", &ModelRegressor::percentile_95_ae, "@DocString_model_reg_percentile_95_ae@")
        .add_property("percentile_95_test_ae", &ModelRegressor::percentile_95_ae, "@DocString_model_reg_test_percentile_95_ae@")
    ;
}

404
405
void sisso::descriptor_identifier::registerModelLogRegressor()
{
406
    class_<ModelLogRegressor, bases<ModelRegressor>>("ModelLogRegressor", init<std::string, Unit, std::vector<double>, std::vector<double>, std::vector<model_node_ptr>, std::vector<int>, std::vector<int>, bool>())
407
408
        .def(init<std::string>())
        .def(init<std::string, std::string>())
409
410
411
        .def("__str__", &ModelLogRegressor::toString, "@DocString_model_log_reg_str@")
        .def("__repr__", &ModelLogRegressor::toString, "@DocString_model_log_reg_str@")
        .add_property("latex_str", &ModelLogRegressor::toLatexString, "@DocString_model_log_reg_latex_str@")
412
413
414
    ;
}

415
416
void sisso::descriptor_identifier::registerModelClassifier()
{
417
    class_<ModelClassifier, bases<Model>>("ModelClassifier", init<std::string, Unit, std::vector<double>, std::vector<double>, std::vector<model_node_ptr>, std::vector<int>, std::vector<int>, bool>())
418
419
        .def(init<std::string>())
        .def(init<std::string, std::string>())
Thomas Purcell's avatar
Thomas Purcell committed
420
421
        .def(init<ModelClassifier, py::list, np::ndarray, np::ndarray>())
        .def(init<ModelClassifier, np::ndarray, np::ndarray, np::ndarray>())
422
423
        .def("__str__", &ModelClassifier::toString, "@DocString_model_class_str@")
        .def("__repr__", &ModelClassifier::toString, "@DocString_model_class_str@")
Thomas Purcell's avatar
Thomas Purcell committed
424
        .def("to_file", &ModelClassifier::to_file_py, "@DocString_model_class_to_file@")
425
        .add_property("latex_str", &ModelClassifier::toLatexString, "@DocString_model_class_latex_str@")
426
427
428
429
430
431
        .add_property("fit", &ModelClassifier::prop_train_est, "@DocString_model_class_prop_train_est@")
        .add_property("predict", &ModelClassifier::prop_test_est, "@DocString_model_class_prop_test_est@")
        .add_property("train_error", &ModelClassifier::train_error, "@DocString_model_class_train_error@")
        .add_property("test_error", &ModelClassifier::test_error, "@DocString_model_class_test_error@")
        .add_property("percent_error", &ModelClassifier::percent_train_error, "@DocString_model_class_precent_train_error@")
        .add_property("percent_test_error", &ModelClassifier::percent_test_error, "@DocString_model_class_precent_test_error@")
Thomas Purcell's avatar
Thomas Purcell committed
432
433
434
435
        .add_property("n_convex_overlap_train", &ModelClassifier::n_convex_overlap_train, "@DocString_model_class_n_convex_overlap_train@")
        .add_property("n_convex_overlap_test", &ModelClassifier::n_convex_overlap_test, "@DocString_model_class_n_convex_overlap_test@")
        .add_property("n_svm_misclassified_train", &ModelClassifier::n_svm_misclassified_train, "@DocString_model_class_n_svm_misclassified_train@")
        .add_property("n_svm_misclassified_test", &ModelClassifier::n_svm_misclassified_test, "@DocString_model_class_n_svm_misclassified_test@")
436
437
438
    ;
}

439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
void sisso::descriptor_identifier::registerSISSO_DI()
{
    class_<sisso::descriptor_identifier::SISSO_DI_Wrap, boost::noncopyable>("SISSO_DI", no_init)
        .add_property("prop", &SISSO_DI::prop_py, "@DocString_sisso_reg_prop_py@")
        .add_property("prop_test", &SISSO_DI::prop_test_py, "@DocString_sisso_reg_prop_test_py@")
        .add_property("n_samp", &SISSO_DI::n_samp, "@DocString_sisso_reg_n_samp@")
        .add_property("n_dim", &SISSO_DI::n_dim, "@DocString_sisso_reg_n_dim@")
        .add_property("n_residual", &SISSO_DI::n_residual, "@DocString_sisso_reg_n_residual@")
        .add_property("n_models_store", &SISSO_DI::n_models_store, "@DocString_sisso_reg_n_models_store@")
        .add_property("feat_space", &SISSO_DI::feat_space, "@DocString_sisso_reg_feat_space@")
        .add_property("task_sizes_train", &SISSO_DI::task_sizes_train, "@DocString_sisso_reg_task_sizes_train@")
        .add_property("task_sizes_test", &SISSO_DI::task_sizes_test, "@DocString_sisso_reg_task_sizes_test@")
    ;
}

454
455
void sisso::descriptor_identifier::registerSISSORegressor()
{
456
    class_<SISSORegressor, bases<SISSO_DI>>("SISSORegressor", init<std::shared_ptr<FeatureSpace>, std::string, Unit, np::ndarray, np::ndarray, py::list, py::list, py::list, int, int, int, optional<bool>>())
457
        .def("fit", &SISSORegressor::fit, "@DocString_sisso_reg_fit@")
458
        .def(init<std::shared_ptr<FeatureSpace>, std::string, Unit, py::list, py::list, py::list, py::list, py::list, int, int, int, optional<bool>>())
459
460
461
462
        .add_property("models", &SISSORegressor::models_py, "@DocString_sisso_reg_models_py@")
    ;
}

463
464
void sisso::descriptor_identifier::registerSISSOLogRegressor()
{
465
    class_<SISSOLogRegressor, bases<SISSORegressor>>("SISSOLogRegressor", init<std::shared_ptr<FeatureSpace>, std::string, Unit, np::ndarray, np::ndarray, py::list, py::list, py::list, int, int, int, optional<bool>>())
466
        .def("fit", &SISSOLogRegressor::fit, "@DocString_sisso_reg_fit@")
467
468
        .def(init<std::shared_ptr<FeatureSpace>, std::string, Unit, py::list, py::list, py::list, py::list, py::list, int, int, int, optional<bool>>())
        .add_property("models", &SISSOLogRegressor::models_log_reg_py, "@DocString_sisso_log_reg_models_py@")
469
470
471
    ;
}

472
473
void sisso::descriptor_identifier::registerSISSOClassifier()
{
474
475
    class_<SISSOClassifier, bases<SISSO_DI>>("SISSOClassifier", init<std::shared_ptr<FeatureSpace>, std::string, Unit, np::ndarray, np::ndarray, py::list, py::list, py::list, int, int, int>())
        .def(init<std::shared_ptr<FeatureSpace>, std::string, Unit, py::list, py::list, py::list, py::list, py::list, int, int, int>())
476
        .def("fit", &SISSOClassifier::fit, "@DocString_sisso_class_fit@")
477
        .add_property("models", &SISSOClassifier::models_py, "@DocString_sisso_class_models_py@")
478
479
    ;
}