8#include <unordered_set>
13string PBSTR =
"====================";
43 vector<type_index> dtypes;
50 for(
i = 0;
i <
X.cols();
i++)
56 for(
j = 0;
j <
X.cols();
j++)
58 if(
X(
i,
j) != 0 &&
X(
i,
j) != 1)
67 dtypes.push_back(
typeid(
ArrayXb));
71 dtypes.push_back(
typeid(
ArrayXi ));
73 dtypes.push_back(
typeid(ArrayXf));
92 _start = high_resolution_clock::now();
96 return high_resolution_clock::now() -
_start;
105 for (
unsigned int i=0;
i<
X.cols(); ++
i)
108 VectorXf
tmp =
X.col(
i).array()-
X.col(
i).mean();
110 scale.push_back(std::sqrt((
tmp.array()).square().sum()/(
tmp.size())));
120 for (
unsigned int i=0;
i<
X.cols(); ++
i)
122 if (std::isinf(
scale.at(
i)))
124 X.col(
i) = VectorXf::Zero(
X.col(
i).size());
165string to_string(const T& value)
167 std::stringstream ss;
183 ArrayXf
svals =
svd.singularValues();
202 MatrixXf
centered =
X.colwise() -
X.rowwise().mean();
208 VectorXf
tmp = 1/
cov.diagonal().array().sqrt();
209 auto d =
tmp.asDiagonal();
222 float N =
tmp.rows()*(
tmp.rows()-1)/2;
224 return tmp.array().square().sum()/
N;
282 {
typeid(
int) ,
"int" },
283 {
typeid(
float) ,
"float" },
284 {
typeid(
bool) ,
"bool" },
285 {
typeid(ArrayXf) ,
"ArrayXf" },
286 {
typeid(
ArrayXi) ,
"ArrayXi" },
287 {
typeid(
ArrayXb) ,
"ArrayXb" }
305 std::vector<float>::iterator
middle =
x.begin() +
x.size()/2;
309 std::vector<float>::iterator
it = std::find(
v.begin(),
v.end(), *
middle);
311 std::vector<float>::size_type
pos = std::distance(
v.begin(),
it);
319 return pow((
v -
v.mean()), 2).mean();
325 float mean =
v.mean();
326 ArrayXf
tmp = mean*ArrayXf::Ones(
v.size());
337 float mean =
v.mean();
338 ArrayXf
tmp = mean*ArrayXf::Ones(
v.size());
349 float meanY = y.mean();
353 ArrayXf
tmp2 =
meanY*ArrayXf::Ones(y.size());
359float slope(
const ArrayXf&
x,
const ArrayXf& y)
379 ArrayXf
dev(
x.size());
380 for (
int i =0;
i <
x.size(); ++
i)
413 for (
int i = 0;
i <
mask.size(); ++
i)
423 tuple<vector<size_t>,vector<size_t>>
indices({},{});
424 for (
int i = 0;
i <
mask.size(); ++
i)
void bind_engine(py::module &m, string name)
std::chrono::duration< float > Elapsed() const
high_resolution_clock::time_point _start
float mean_square_corrcoef(const MatrixXf &X)
std::string ReplaceString(std::string subject, const std::string &search, const std::string &replace)
find and replace string
MatrixXf corrcoef(const MatrixXf &X)
returns the pearson correlation coefficients of matrix.
vector< type_index > get_dtypes(MatrixXf &X)
calculates data types for each column of X
float slope(const ArrayXf &x, const ArrayXf &y)
slope of x/y
float mad(const ArrayXf &x)
median absolute deviation
float condition_number(const MatrixXf &X)
returns true for elements of x that are infinite
std::string ltrim(std::string str, const std::string &chars)
float skew(const ArrayXf &v)
calculate skew
float pearson_correlation(const ArrayXf &x, const ArrayXf &y)
the normalized covariance of x and y
tuple< vector< size_t >, vector< size_t > > mask_to_indices(const ArrayXb &mask)
returns 2 indices: first where mask is true, and second where mask is false.
Scalar median(const T &v)
calculate median
void clean(ArrayXf &x)
limits node output to be between MIN_FLT and MAX_FLT
float kurtosis(const ArrayXf &v)
calculate kurtosis
TypeMap< std::string > type_names
std::string rtrim(std::string str, const std::string &chars)
void ReplaceStringInPlace(std::string &subject, const std::string &search, const std::string &replace)
string find and replace in place
std::string trim(std::string str, const std::string &chars)
float variance(const ArrayXf &v)
calculate variance
std::map< std::type_index, T > TypeMap
float covariance(const ArrayXf &x, const ArrayXf &y)
covariance of x and y
int argmiddle(vector< float > &v)
returns the (first) index of the element with the middlest value in v
vector< size_t > mask_to_index(const ArrayXb &mask)
convert a boolean mask to an index array
< nsga2 selection operator for getting the front
Eigen::Array< bool, Eigen::Dynamic, 1 > ArrayXb
Eigen::Array< int, Eigen::Dynamic, 1 > ArrayXi
vector< unsigned > max_size
void update(int index, float timer_count, float bst_score, float bst_score_v, float md_score, float md_score_v, unsigned md_size, unsigned md_complexity, unsigned mx_size, unsigned mx_complexity)
vector< unsigned > max_complexity
vector< float > med_score_v
vector< unsigned > med_size
vector< float > med_score
vector< float > best_score_v
vector< unsigned > med_complexity
vector< float > best_score
void fit(MatrixXf &X, const vector< char > &dt)
fit the scale and offset of data.
void fit_normalize(MatrixXf &X, const vector< char > &dtypes)
void normalize(MatrixXf &X)
normalize matrix.