12 #include <shogun/base/init.h>
35 #define initialize_cuda() 0
39 using Eigen::MatrixXf;
40 using Eigen::ArrayXXf;
41 using Eigen::VectorXf;
43 typedef Eigen::Array<bool,Eigen::Dynamic,1>
ArrayXb;
46 using std::unique_ptr;
47 using std::shared_ptr;
48 using std::make_shared;
50 namespace nl = nlohmann;
111 void set_pop_size(
int pop_size);
116 void set_gens(
int gens);
121 void set_ml(
string ml);
126 void set_classification(
bool classification);
128 bool get_classification();
131 void set_verbosity(
int verbosity);
136 void set_max_stall(
int max_stall);
141 void set_selection(
string sel);
144 void set_survival(
string surv);
147 float get_cross_rate();
149 void set_cross_rate(
float cross_rate);
152 void set_root_xo_rate(
float cross_rate);
156 vector<char> get_otypes();
160 void set_otype(
char ot);
163 void set_functions(
const vector<string>& fns){ params.set_functions(fns); };
169 void set_max_depth(
unsigned int max_depth);
174 void set_max_dim(
unsigned int max_dim);
180 void set_random_state(
int random_state);
188 void set_erc(
bool erc);
193 void set_shuffle(
bool sh);
199 void set_split(
float sp);
202 vector<char> get_dtypes();
204 void set_dtypes(vector<char> dtypes);
209 void set_fb(
float fb);
212 string get_logfile();
214 void set_logfile(
string s);
219 void set_scorer(
string s);
221 string get_scorer_();
227 void set_backprop(
bool bp);
230 void set_simplify(
float s);
233 void set_corr_delete_mutate(
bool s);
236 void set_hillclimb(
bool hc);
239 void set_iters(
int iters);
242 void set_lr(
float lr);
243 float get_lr(){
return params.bp.learning_rate;};
246 void set_batch_size(
int bs);
249 void set_n_jobs(
unsigned t);
253 void set_max_time(
int time);
257 void set_use_batch();
283 string get_sel(){
return this->selector.get_type();};
286 string get_surv(){
return this->survivor.get_type();};
303 void set_protected_groups(
string pg);
316 int get_num_features();
318 string get_representation();
320 string get_model(
bool sort=
true);
322 string get_ind_eqn(
bool sort,
Individual& ind);
323 string get_eqn(
bool sort=
false);
329 int get_complexity();
331 vector<nl::json> get_archive(
bool front);
338 int * idx,
int idx_size);
343 void fit(MatrixXf& X, VectorXf& y);
344 void fit(MatrixXf& X, VectorXf& y,
LongData& Z);
346 void run_generation(
unsigned int g,
347 vector<size_t> survivors,
351 unsigned& stall_count);
354 VectorXf predict(MatrixXf& X,
LongData& Z);
355 VectorXf predict(MatrixXf& X);
358 VectorXf predict_archive(
int id, MatrixXf& X);
359 VectorXf predict_archive(
int id, MatrixXf& X,
LongData& Z);
360 ArrayXXf predict_proba_archive(
int id, MatrixXf& X,
LongData& Z);
361 ArrayXXf predict_proba_archive(
int id, MatrixXf& X);
367 ArrayXXf predict_proba(MatrixXf& X,
LongData& Z);
368 ArrayXXf predict_proba(MatrixXf& X);
371 MatrixXf transform(MatrixXf& X);
372 MatrixXf transform(MatrixXf& X,
LongData& Z);
376 float score(MatrixXf& X,
const VectorXf& y,
380 nl::json get_stats();
383 void load_best_ind(
string filename);
386 void load_population(
string filename,
bool justfront=
false);
390 void load(
const json& j);
392 void load_from_file(
string filename);
396 void save_to_file(
string filename);
430 bool update_best(
const DataRef& d,
bool val=
false);
433 void calculate_stats(
const DataRef& d);
434 void print_stats(std::ofstream& log,
436 void log_stats(std::ofstream& log);
439 vector<float> univariate_initial_model(
DataRef &d,
int n_feats);
441 void initial_model(
DataRef &d);
447 void update_stall_count(
unsigned& stall_count,
bool updated);
evaluation mixin class for Feat
main class for the Feat learner.
void set_functions(const vector< string > &fns)
sets available functions based on comma-separated list.
void set_starting_pop(string sp)
int get_archive_size()
return archive size
void set_normalize(bool in)
void set_feature_names(string s)
void set_tune_initial(bool in)
void set_tune_final(bool in)
int save_pop
controls whether pop is printed each gen
string starting_pop
file with starting population
float simplify
post-run simplification
void set_val_from_arch(bool in)
int best_complexity
complexity of the best model
float min_loss
current best score
void set_is_fitted(bool f)
set flag indicating whether fit has been called
Population pop
population of programs
bool use_arch
internal control over use of archive
int get_random_state_()
returns the actual seed determined by the input argument.
auto get_objectives()
get objectives for multi-objective search
char get_otype()
return parameter otype, used to set otypes
bool val_from_arch
model selection only uses Pareto front
Individual best_ind
best individual
Log_Stats stats
runtime stats
bool get_corr_delete_mutate()
string get_protected_groups()
void set_residual_xo(bool res_xo=true)
use residual crossover
Variation variator
variation operators
string str_dim
dimensionality as multiple of number of cols
string survival
stores survival mode
void set_objectives(const vector< string > &obj)
set objectives for multi-objective search
void set_stagewise_xo_tol(int tol)
Evaluation evaluator
evaluation code
string get_feature_names()
Selection selector
selection algorithm
float min_loss_v
best validation score
string logfile
log filename
Parameters params
hyperparameters of Feat
int get_stagewise_xo_tol()
bool is_fitted
keeps track of whether fit was called.
Archive archive
pareto front archive
void set_softmax_norm(bool sftmx=true)
use softmax
vector< string > get_functions()
void set_stagewise_xo(bool sem_xo=true)
use stagewise crossover
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Feat, params, pop, selector, survivor, archive, use_arch, survival, N, min_loss, min_loss_v, best_med_score, best_complexity, str_dim, starting_pop, best_ind, is_fitted)
string get_starting_pop()
float best_med_score
best median population score
Feat()
member initializer list constructor
Selection survivor
survival algorithm
Timer timer
start time of training
Normalizer N
scales training data.
void set_save_pop(int pp)
individual programs in the population
std::map< string, std::pair< vector< ArrayXf >, vector< ArrayXf > > > LongData
Eigen::Array< bool, Eigen::Dynamic, 1 > ArrayXb
#define omp_get_num_threads()
bool in(const vector< T > v, const T &i)
check if element is in vector.
void from_json(const nl::json &, Feat &)
void to_json(nl::json &, const Feat &)
holds the hyperparameters for Feat.
Defines a population of programs and functions for constructing them.
interfaces with selection operators.
normalizes a matrix to unit variance, 0 mean centered.