Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
bind_search_space.cpp
Go to the documentation of this file.
1#include "module.h"
4namespace py = pybind11;
5namespace br = Brush;
6namespace nl = nlohmann;
7
8using stream_redirect = py::call_guard<py::scoped_ostream_redirect, py::scoped_estream_redirect>;
9
10void bind_search_space(py::module &m)
11{
12 // Notice: We change the interface for SearchSpace a little bit by
13 // constructing it with a Dataset object, rather than initializing it as an
14 // empty struct and then calling init() with the Dataset object.
15 py::class_<br::SearchSpace>(m, "SearchSpace")
16 .def(py::init([](br::Data::Dataset data, bool weights_init=true){
18 SS.init(data, {}, weights_init);
19 return SS;
20 }),
21 py::arg("data"),
22 py::arg("weights_init") = true )
23 .def(py::init<const Dataset&, const unordered_map<string,float>&,
24 bool>(),
25 py::arg("data"),
26 py::arg("user_ops"),
27 py::arg("weights_init") = true )
28 .def("make_regressor", &br::SearchSpace::make_regressor,
29 py::arg("max_d") = 0,
30 py::arg("max_size") = 0,
31 py::arg("params") = Brush::Parameters() )
32 .def("make_classifier", &br::SearchSpace::make_classifier,
33 py::arg("max_d") = 0,
34 py::arg("max_size") = 0,
35 py::arg("params") = Brush::Parameters() )
36 .def("make_multiclass_classifier",
37 &br::SearchSpace::make_multiclass_classifier,
38 py::arg("max_d") = 0,
39 py::arg("max_size") = 0,
40 py::arg("params") = Brush::Parameters() )
41 .def("make_representer", &br::SearchSpace::make_representer,
42 py::arg("max_d") = 0,
43 py::arg("max_size") = 0,
44 py::arg("params") = Brush::Parameters() )
45 .def("print",
46 &br::SearchSpace::print,
48 )
49 ;
50}
void bind_engine(py::module &m, string name)
py::call_guard< py::scoped_ostream_redirect, py::scoped_estream_redirect > stream_redirect
void bind_search_space(py::module &m)
py::call_guard< py::scoped_ostream_redirect, py::scoped_estream_redirect > stream_redirect
holds variable type data.
Definition data.h:51
< nsga2 selection operator for getting the front
Definition data.cpp:12
SearchSpace SS
Holds a search space, consisting of operations and terminals and functions, and methods to sample tha...
void init(const Dataset &d, const unordered_map< string, float > &user_ops={}, bool weights_init=true)
Called by the constructor to initialize the search space.