Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
Brush::Engine< T > Class Template Reference

The Engine class represents the core engine of the brush library. More...

#include <engine.h>

Collaboration diagram for Brush::Engine< T >:

Public Member Functions

 Engine (const Parameters &p=Parameters())
 
 ~Engine ()
 
void print_progress (float percentage)
 
void calculate_stats ()
 
void print_stats (std::ofstream &log, float fraction)
 
void log_stats (std::ofstream &log)
 
Parametersget_params ()
 
void set_params (Parameters &p)
 
bool get_is_fitted ()
 
bool update_best (const Dataset &data, bool val=false)
 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 population as string
 
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

float best_score
 
int best_complexity
 
Parameters params
 hyperparameters of brush, which the user can interact
 
Individual< T > best_ind
 
Archive< T > archive
 pareto front archive
 

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

SearchSpace ss
 
Population< T > pop
 population of programs
 
Selection< T > selector
 selection algorithm
 
Evaluation< T > evaluator
 evaluation code
 
Variation< T > variator
 variation operators
 
Selection< T > survivor
 survival algorithm
 
Log_Stats stats
 runtime stats
 
Timer timer
 start time of training
 
bool is_fitted
 keeps track of whether fit was called.
 

Detailed Description

template<ProgramType T>
class Brush::Engine< T >

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.

Definition at line 43 of file engine.h.

Constructor & Destructor Documentation

◆ Engine()

template<ProgramType T>
Brush::Engine< T >::Engine ( const Parameters & p = Parameters())
inline

Definition at line 45 of file engine.h.

◆ ~Engine()

template<ProgramType T>
Brush::Engine< T >::~Engine ( )
inline

Definition at line 51 of file engine.h.

Member Function Documentation

◆ calculate_stats()

template<ProgramType T>
void Brush::Engine< T >::calculate_stats ( )

Definition at line 62 of file engine.cpp.

Here is the call graph for this function:

◆ fit() [1/2]

template<ProgramType T>
Engine< T > & Brush::Engine< T >::fit ( const Ref< const ArrayXXf > & X,
const Ref< const ArrayXf > & y )
inline

Definition at line 79 of file engine.h.

Here is the call graph for this function:

◆ fit() [2/2]

template<ProgramType T>
Engine< T > & Brush::Engine< T >::fit ( Dataset & data)
inline

Definition at line 75 of file engine.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_archive()

template<ProgramType T>
vector< json > Brush::Engine< T >::get_archive ( bool front)

return population as string

Definition at line 191 of file engine.cpp.

Here is the call graph for this function:

◆ get_archive_size()

template<ProgramType T>
int Brush::Engine< T >::get_archive_size ( )
inline

return archive size

Definition at line 106 of file engine.h.

◆ get_best_ind()

template<ProgramType T>
Individual< T > & Brush::Engine< T >::get_best_ind ( )
inline

Definition at line 73 of file engine.h.

◆ get_is_fitted()

template<ProgramType T>
bool Brush::Engine< T >::get_is_fitted ( )
inline

Definition at line 63 of file engine.h.

◆ get_params()

template<ProgramType T>
Parameters & Brush::Engine< T >::get_params ( )
inline

Definition at line 60 of file engine.h.

◆ init()

template<ProgramType T>
void Brush::Engine< T >::init ( )
private

initialize Feat object for fitting.

Definition at line 18 of file engine.cpp.

Here is the call graph for this function:

◆ log_stats()

template<ProgramType T>
void Brush::Engine< T >::log_stats ( std::ofstream & log)

Definition at line 129 of file engine.cpp.

Here is the call graph for this function:

◆ predict() [1/2]

template<ProgramType T>
auto Brush::Engine< T >::predict ( const Dataset & data)
inline

Definition at line 87 of file engine.h.

Here is the caller graph for this function:

◆ predict() [2/2]

template<ProgramType T>
auto Brush::Engine< T >::predict ( const Ref< const ArrayXXf > & X)
inline

Definition at line 88 of file engine.h.

Here is the call graph for this function:

◆ predict_archive() [1/2]

template<ProgramType T>
auto Brush::Engine< T >::predict_archive ( int id,
const Dataset & data )

predict on unseen data from the archive

Definition at line 208 of file engine.cpp.

Here is the call graph for this function:

◆ predict_archive() [2/2]

template<ProgramType T>
auto Brush::Engine< T >::predict_archive ( int id,
const Ref< const ArrayXXf > & X )

Definition at line 239 of file engine.cpp.

Here is the call graph for this function:

◆ predict_proba() [1/2]

template<ProgramType T>
template<ProgramType P = T>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
auto Brush::Engine< T >::predict_proba ( const Dataset & d)
inline

Definition at line 96 of file engine.h.

Here is the caller graph for this function:

◆ predict_proba() [2/2]

template<ProgramType T>
template<ProgramType P = T>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
auto Brush::Engine< T >::predict_proba ( const Ref< const ArrayXXf > & X)
inline

Definition at line 99 of file engine.h.

Here is the call graph for this function:

◆ predict_proba_archive() [1/2]

template<ProgramType T>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
template<ProgramType P>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
auto Brush::Engine< T >::predict_proba_archive ( int id,
const Dataset & data )

Definition at line 248 of file engine.cpp.

Here is the call graph for this function:

◆ predict_proba_archive() [2/2]

template<ProgramType T>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
template<ProgramType P>
requires ((P == PT::BinaryClassifier) || (P == PT::MulticlassClassifier))
auto Brush::Engine< T >::predict_proba_archive ( int id,
const Ref< const ArrayXXf > & X )

Definition at line 281 of file engine.cpp.

Here is the call graph for this function:

◆ print_progress()

template<ProgramType T>
void Brush::Engine< T >::print_progress ( float percentage)

Definition at line 46 of file engine.cpp.

Here is the call graph for this function:

◆ print_stats()

template<ProgramType T>
void Brush::Engine< T >::print_stats ( std::ofstream & log,
float fraction )

Definition at line 159 of file engine.cpp.

Here is the call graph for this function:

◆ run()

template<ProgramType T>
void Brush::Engine< T >::run ( Dataset & d)

train the model

Definition at line 324 of file engine.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_is_fitted()

template<ProgramType T>
void Brush::Engine< T >::set_is_fitted ( bool f)
inlineprivate

set flag indicating whether fit has been called

Definition at line 149 of file engine.h.

Here is the call graph for this function:

◆ set_params()

template<ProgramType T>
void Brush::Engine< T >::set_params ( Parameters & p)
inline

Definition at line 61 of file engine.h.

Here is the call graph for this function:

◆ update_best()

template<ProgramType T>
bool Brush::Engine< T >::update_best ( const Dataset & data,
bool val = false )

updates best score by searching in the population for the individual that best fits the given data

Definition at line 288 of file engine.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ archive

template<ProgramType T>
Archive<T> Brush::Engine< T >::archive

pareto front archive

Definition at line 130 of file engine.h.

◆ best_complexity

template<ProgramType T>
int Brush::Engine< T >::best_complexity

Definition at line 72 of file engine.h.

◆ best_ind

template<ProgramType T>
Individual<T> Brush::Engine< T >::best_ind

Definition at line 128 of file engine.h.

◆ best_score

template<ProgramType T>
float Brush::Engine< T >::best_score

Definition at line 71 of file engine.h.

◆ evaluator

template<ProgramType T>
Evaluation<T> Brush::Engine< T >::evaluator
private

evaluation code

Definition at line 136 of file engine.h.

◆ is_fitted

template<ProgramType T>
bool Brush::Engine< T >::is_fitted
private

keeps track of whether fit was called.

Definition at line 144 of file engine.h.

◆ params

template<ProgramType T>
Parameters Brush::Engine< T >::params

hyperparameters of brush, which the user can interact

Definition at line 127 of file engine.h.

◆ pop

template<ProgramType T>
Population<T> Brush::Engine< T >::pop
private

population of programs

Definition at line 134 of file engine.h.

◆ selector

template<ProgramType T>
Selection<T> Brush::Engine< T >::selector
private

selection algorithm

Definition at line 135 of file engine.h.

◆ ss

template<ProgramType T>
SearchSpace Brush::Engine< T >::ss
private

Definition at line 132 of file engine.h.

◆ stats

template<ProgramType T>
Log_Stats Brush::Engine< T >::stats
private

runtime stats

Definition at line 140 of file engine.h.

◆ survivor

template<ProgramType T>
Selection<T> Brush::Engine< T >::survivor
private

survival algorithm

Definition at line 138 of file engine.h.

◆ timer

template<ProgramType T>
Timer Brush::Engine< T >::timer
private

start time of training

Definition at line 142 of file engine.h.

◆ variator

template<ProgramType T>
Variation<T> Brush::Engine< T >::variator
private

variation operators

Definition at line 137 of file engine.h.


The documentation for this class was generated from the following files: