Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
inexact.cpp
Go to the documentation of this file.
1#include "inexact.h"
2#include "../util/rnd.h"
3
5
6// simplification maps are based on trainingdata
7// should ignore fixed nodes ---> does not change subtrees if they contain fixed nodes
8// should I implement json serialization?
9
10namespace Brush { namespace Simpl{
11
12// Inexact_simplifier* Inexact_simplifier::instance = NULL;
13
17
18
19void Inexact_simplifier::init(int hashSize, const Dataset &data, int numPlanes)
20{
21 // The greater the number of planes, the more accurate the hash, but the slower the search
22
23 // cut-off for performance at 100 samples
25
26 uniformPlanes.clear();
27 for (int i=0; i<numPlanes; ++i)
28 {
29 // Use deterministic random number generator instead of Eigen::Random()
30 // to ensure reproducibility with seed
31 MatrixXf plane(hashSize, inputDim);
32 for (int row = 0; row < hashSize; ++row) {
33 for (int col = 0; col < inputDim; ++col) {
34 plane(row, col) = r.rnd_flt(-1.0f, 1.0f);
35 }
36 }
37 // plane /= plane.norm();
38 uniformPlanes.push_back(plane);
39 }
40
42 for (const auto& dtype : data.unique_data_types)
43 equivalentExpressions[dtype] = HashStorage(numPlanes);
44}
45
46
48
49} // Simply
50} // Brush
holds variable type data.
Definition data.h:51
int get_n_samples() const
Definition data.h:225
std::vector< DataType > unique_data_types
keeps track of the unique data types in the dataset.
Definition data.h:64
Dataset get_training_data() const
Definition data.cpp:214
vector< MatrixXf > uniformPlanes
Definition inexact.h:434
void init(int hashSize, const Dataset &data, int numPlanes)
Definition inexact.cpp:19
std::unordered_map< DataType, HashStorage > equivalentExpressions
Definition inexact.h:432
static Rnd & r
Definition rnd.h:176
< nsga2 selection operator for getting the front
Definition bandit.cpp:4