Brush C++ API
A flexible interpretable machine learning framework
|
The Engine
class represents the core engine of the brush library.
More...
#include <engine.h>
Public Member Functions | |
Engine () | |
Engine (Parameters &p, SearchSpace &s) | |
~Engine () | |
void | print_progress (float percentage) |
void | calculate_stats () |
void | print_stats (std::ofstream &log, float fraction) |
void | log_stats (std::ofstream &log) |
Parameters & | get_params () |
void | set_params (Parameters &p) |
SearchSpace & | get_search_space () |
void | set_search_space (SearchSpace &space) |
bool | get_is_fitted () |
bool | update_best () |
updates best score by searching in the population for the individual that best fits the given data | |
Individual< T > & | get_best_ind () |
Engine< T > & | fit (Dataset &data) |
Engine< T > & | fit (const Ref< const ArrayXXf > &X, const Ref< const ArrayXf > &y) |
auto | predict (const Dataset &data) |
auto | predict (const Ref< const ArrayXXf > &X) |
template<ProgramType P = T> requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier)) | |
auto | predict_proba (const Dataset &d) |
template<ProgramType P = T> requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier)) | |
auto | predict_proba (const Ref< const ArrayXXf > &X) |
int | get_archive_size () |
return archive size | |
vector< json > | get_archive (bool front) |
return archive/population as string | |
vector< json > | get_population () |
void | set_population (vector< json > pop_vector) |
void | lock_nodes (int end_depth=0, bool skip_leaves=true) |
void | unlock_nodes (int start_depth=0) |
auto | predict_archive (int id, const Dataset &data) |
predict on unseen data from the archive | |
auto | predict_archive (int id, const Ref< const ArrayXXf > &X) |
template<ProgramType P = T> requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier)) | |
auto | predict_proba_archive (int id, const Dataset &data) |
template<ProgramType P = T> requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier)) | |
auto | predict_proba_archive (int id, const Ref< const ArrayXXf > &X) |
void | run (Dataset &d) |
train the model | |
Public Attributes | |
Parameters | params |
hyperparameters of brush, which the user can interact | |
SearchSpace | ss |
Individual< T > | best_ind |
best individual found during training | |
Archive< T > | archive |
pareto front archive | |
Population< T > | pop |
population of programs | |
bool | is_fitted = false |
keeps track of whether fit was called | |
Private Member Functions | |
void | init () |
initialize Feat object for fitting. | |
void | set_is_fitted (bool f) |
set flag indicating whether fit has been called | |
Private Attributes | |
Selection< T > | selector |
selection algorithm | |
Evaluation< T > | evaluator |
evaluation code | |
Selection< T > | survivor |
survival algorithm | |
Log_Stats | stats |
runtime stats | |
Timer | timer |
start time of training | |
The Engine
class represents the core engine of the brush library.
It encapsulates the functionality for training and predicting with programs in a genetic programming framework. The Engine
class manages the population of programs, selection algorithms, evaluation code, variation operators, and survival algorithms. It also provides methods for training the model, making predictions, and accessing runtime statistics.
The Engine
class is parameterized by the program type T
, which determines the type of programs that can be evolved and evaluated by the engine.
|
inline |
|
inline |
|
inline |
void Brush::Engine< T >::calculate_stats | ( | ) |
|
inline |
|
inline |
vector< json > Brush::Engine< T >::get_archive | ( | bool | front | ) |
return archive/population as string
Definition at line 182 of file engine.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
vector< json > Brush::Engine< T >::get_population | ( | ) |
|
inline |
|
private |
initialize Feat object for fitting.
Definition at line 16 of file engine.cpp.
void Brush::Engine< T >::lock_nodes | ( | int | end_depth = 0, |
bool | skip_leaves = true ) |
Definition at line 326 of file engine.cpp.
void Brush::Engine< T >::log_stats | ( | std::ofstream & | log | ) |
|
inline |
|
inline |
auto Brush::Engine< T >::predict_archive | ( | int | id, |
const Dataset & | data ) |
predict on unseen data from the archive
Definition at line 246 of file engine.cpp.
auto Brush::Engine< T >::predict_archive | ( | int | id, |
const Ref< const ArrayXXf > & | X ) |
|
inline |
|
inline |
auto Brush::Engine< T >::predict_proba_archive | ( | int | id, |
const Dataset & | data ) |
Definition at line 286 of file engine.cpp.
auto Brush::Engine< T >::predict_proba_archive | ( | int | id, |
const Ref< const ArrayXXf > & | X ) |
void Brush::Engine< T >::print_progress | ( | float | percentage | ) |
void Brush::Engine< T >::print_stats | ( | std::ofstream & | log, |
float | fraction ) |
void Brush::Engine< T >::run | ( | Dataset & | d | ) |
train the model
Definition at line 403 of file engine.cpp.
|
inlineprivate |
|
inline |
void Brush::Engine< T >::set_population | ( | vector< json > | pop_vector | ) |
|
inline |
void Brush::Engine< T >::unlock_nodes | ( | int | start_depth = 0 | ) |
Definition at line 341 of file engine.cpp.
bool Brush::Engine< T >::update_best | ( | ) |
updates best score by searching in the population for the individual that best fits the given data
Definition at line 357 of file engine.cpp.
Archive<T> Brush::Engine< T >::archive |
Individual<T> Brush::Engine< T >::best_ind |
|
private |
bool Brush::Engine< T >::is_fitted = false |
Parameters Brush::Engine< T >::params |
Population<T> Brush::Engine< T >::pop |
|
private |
SearchSpace Brush::Engine< T >::ss |
|
private |
|
private |
|
private |