Brush C++ API
A flexible interpretable machine learning framework
Toggle main menu visibility
Loading...
Searching...
No Matches
inexact.cpp
Go to the documentation of this file.
1
#include "
inexact.h
"
2
#include "
../util/rnd.h
"
3
4
using
Brush::Util::r
;
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
10
namespace
Brush
{
namespace
Simpl
{
11
12
// Inexact_simplifier* Inexact_simplifier::instance = NULL;
13
14
Inexact_simplifier::Inexact_simplifier
()
15
{
16
}
17
18
19
void
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
24
inputDim
= std::min(
inputDim
, data.
get_training_data
().
get_n_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
41
equivalentExpressions
.clear();
42
for
(
const
auto
& dtype : data.
unique_data_types
)
43
equivalentExpressions
[dtype] =
HashStorage
(numPlanes);
44
}
45
46
47
Inexact_simplifier::~Inexact_simplifier
() {}
48
49
}
// Simply
50
}
// Brush
Brush::Data::Dataset
holds variable type data.
Definition
data.h:51
Brush::Data::Dataset::get_n_samples
int get_n_samples() const
Definition
data.h:225
Brush::Data::Dataset::unique_data_types
std::vector< DataType > unique_data_types
keeps track of the unique data types in the dataset.
Definition
data.h:64
Brush::Data::Dataset::get_training_data
Dataset get_training_data() const
Definition
data.cpp:214
Brush::Simpl::HashStorage
Definition
inexact.h:16
Brush::Simpl::Inexact_simplifier::Inexact_simplifier
Inexact_simplifier()
Definition
inexact.cpp:14
Brush::Simpl::Inexact_simplifier::uniformPlanes
vector< MatrixXf > uniformPlanes
Definition
inexact.h:434
Brush::Simpl::Inexact_simplifier::~Inexact_simplifier
~Inexact_simplifier()
Definition
inexact.cpp:47
Brush::Simpl::Inexact_simplifier::init
void init(int hashSize, const Dataset &data, int numPlanes)
Definition
inexact.cpp:19
Brush::Simpl::Inexact_simplifier::equivalentExpressions
std::unordered_map< DataType, HashStorage > equivalentExpressions
Definition
inexact.h:432
Brush::Simpl::Inexact_simplifier::inputDim
int inputDim
Definition
inexact.h:290
inexact.h
Brush::Simpl
Definition
constants.cpp:4
Brush::Util::r
static Rnd & r
Definition
rnd.h:176
Brush
< nsga2 selection operator for getting the front
Definition
bandit.cpp:3
rnd.h
src
simplification
inexact.cpp
Generated by
1.17.0