7 #include <pybind11/pybind11.h>
8 #include <pybind11/eigen.h>
9 #include <pybind11/stl.h>
10 #include <pybind11/iostream.h>
12 #include "pybind11_json/pybind11_json.hpp"
13 #include "nlohmann/json.hpp"
26 #define STRINGIFY(x) #x
27 #define MACRO_STRINGIFY(x) STRINGIFY(x)
29 namespace py = pybind11;
31 namespace nl = nlohmann;
32 using namespace pybind11::literals;
37 Python binding for Feat
38 --------------------------
51 py::class_<Feat>(m,
"cppFeat", py::dynamic_attr())
54 {
Feat est;
return est; }))
97 .def_property(
"protected_groups",
104 py::overload_cast<MatrixXf &, VectorXf &>(&
Feat::fit),
106 py::scoped_ostream_redirect,
107 py::scoped_estream_redirect,
108 py::gil_scoped_release>(),
111 py::overload_cast<MatrixXf &, VectorXf &, LongData &>(&
Feat::fit),
113 py::scoped_ostream_redirect,
114 py::scoped_estream_redirect,
115 py::gil_scoped_release>(),
116 "fit from X,y,Z data")
119 "transform from X data")
122 "transform from X,Z data")
125 "predict from X data")
128 "predict from X,Z data")
129 .def(
"predict_proba",
131 "predict probabilities from X data")
132 .def(
"predict_proba",
134 "predict probabilities from X data")
135 .def(
"predict_archive",
137 "predict from individual in archive")
138 .def(
"predict_archive",
140 "predict from individual in archive")
141 .def(
"predict_proba_archive",
143 "predict from individual in archive")
144 .def(
"predict_proba_archive",
146 "predict from individual in archive")
main class for the Feat learner.
void set_backprop(bool bp)
set constant optimization options
int get_dim()
get dimensionality of best
void set_functions(const vector< string > &fns)
sets available functions based on comma-separated list.
void set_starting_pop(string sp)
void set_normalize(bool in)
void set_root_xo_rate(float cross_rate)
set root xo rate in variation
void set_feature_names(string s)
ArrayXXf predict_proba(MatrixXf &X, LongData &Z)
predict probabilities of each class.
void load(const json &j)
load Feat state from a json string.
void set_random_state(int random_state)
set dimensionality as multiple of the number of columns
void set_corr_delete_mutate(bool s)
void set_tune_initial(bool in)
string get_model(bool sort=true)
return best model, in tabular form
void set_tune_final(bool in)
void set_gens(int gens)
set size of max generations
void set_split(float sp)
set train fraction of dataset
void set_erc(bool erc)
flag to set whether to use variable or constants for terminals
void set_val_from_arch(bool in)
void set_classification(bool classification)
set EProblemType for shogun
float get_split()
return fraction of data to use for training
void set_scorer(string s)
set scoring function
int get_max_depth()
return max_depth of programs
void set_fb(float fb)
set feedback
void set_max_time(int time)
set max time in seconds for fit method
json save() const
save and return a json Feat state as string.
string get_representation()
return best model
ArrayXf get_coefs()
return the coefficients or importance scores of the best model.
int get_n_params()
get number of parameters in best
void set_protected_groups(string pg)
set protected groups for fairness
void set_simplify(float s)
bool get_erc()
return boolean value of erc flag
int get_verbosity()
return current verbosity level set
auto get_objectives()
get objectives for multi-objective search
MatrixXf transform(MatrixXf &X)
transform an input matrix using a program.
char get_otype()
return parameter otype, used to set otypes
bool get_classification()
return type of classification flag set
int get_max_stall()
return maximum stall in learning, in generations
VectorXf predict_archive(int id, MatrixXf &X)
predict on unseen data from the whole archive
nl::json get_stats()
return statistics from the run as a json string
bool get_corr_delete_mutate()
int get_pop_size()
return population size
string get_protected_groups()
void set_iters(int iters)
string get_eqn(bool sort=false)
vector< nl::json > get_archive(bool front)
return population as string
void set_pop_size(int pop_size)
set size of population
void set_residual_xo(bool res_xo=true)
use residual crossover
void set_n_jobs(unsigned t)
set number of threads
void set_objectives(const vector< string > &obj)
set objectives for multi-objective search
void set_hillclimb(bool hc)
void set_otype(char ot)
set program output type ('f', 'b')
void set_ml(string ml)
set ML algorithm to use
int get_max_dim()
return max dimensionality of programs
void set_stagewise_xo_tol(int tol)
string get_feature_names()
void set_logfile(string s)
set name for files
int get_gens()
return size of max generations
void set_shuffle(bool sh)
flag to shuffle the input samples for train/test splits
int get_n_nodes()
return the number of nodes in the best model
string get_logfile()
get name
string get_ml()
return ML algorithm string
int get_stagewise_xo_tol()
void set_max_dim(unsigned int max_dim)
set maximum dimensionality of programs
void set_max_depth(unsigned int max_depth)
set max depth of programs
void set_softmax_norm(bool sftmx=true)
use softmax
vector< string > get_functions()
void set_stagewise_xo(bool sem_xo=true)
use stagewise crossover
void set_verbosity(int verbosity)
set level of debug info
string get_starting_pop()
ArrayXXf predict_proba_archive(int id, MatrixXf &X, LongData &Z)
void set_cross_rate(float cross_rate)
set cross rate in variation
void set_batch_size(int bs)
float get_fb()
get feedback setting
bool get_shuffle()
return whether option to shuffle the data is set or not
float get_cross_rate()
return cross rate for variation
VectorXf predict(MatrixXf &X, LongData &Z)
predict on unseen data.
void fit(MatrixXf &X, VectorXf &y)
train a model.
void set_max_stall(int max_stall)
set maximum stall in learning, in generations
void set_save_pop(int pp)
PYBIND11_MODULE(_feat, m)