Commit 91ddd24c authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Test the new phi output

Testing the phi ouput scheme
parent de2ee8fa
......@@ -154,6 +154,13 @@ FeatureSpace::FeatureSpace(InputParser inputs):
double start = omp_get_wtime();
generate_feature_space(_phi, _start_rung, _prop_train);
_n_feat = _phi.size();
if(_phi_out_file.size() > 0)
{
output_phi();
}
_mpi_comm->barrier();
double duration = omp_get_wtime() - start;
if(_mpi_comm->rank() == 0)
......@@ -779,15 +786,6 @@ void FeatureSpace::generate_feature_space(
}
#endif
}
if(!reparam)
{
_n_feat = feat_set.size();
}
if(_phi_out_file.size() > 0)
{
output_phi();
}
}
void FeatureSpace::generate_and_project(std::shared_ptr<LossFunction> loss, std::vector<node_ptr>& phi_sel, std::vector<double>& scores_sel)
......@@ -1213,6 +1211,7 @@ void FeatureSpace::remove_feature(const int ind)
}
_phi.erase(_phi.begin() + ind);
--_n_feat;
}
void FeatureSpace::output_phi()
......
......@@ -95,12 +95,6 @@ CbrtNode::CbrtNode(const node_ptr feat, const unsigned long int feat_ind, const
throw InvalidFeatureException();
}
double* val_ptr = feat->value_ptr(rung() + 2);
if(*std::min_element(val_ptr, val_ptr + _n_samp) < 0.0)
{
throw InvalidFeatureException();
}
set_value();
// Check if the feature is NaN, greater than the allowed max of less than the allowed min
......
......@@ -63,7 +63,7 @@ void generateDivNode(std::vector<node_ptr>& feat_list, const node_ptr feat_1, co
double div_mult_tot_first = div_mult_leaves.begin()->second;
if(
(std::abs(div_mult_tot_first) != 1.0) &&
std::all_of(div_mult_leaves.begin(), div_mult_leaves.end(), [&div_mult_tot_first](auto el){return el.second == div_mult_tot_first;})
std::all_of(div_mult_leaves.begin(), div_mult_leaves.end(), [&div_mult_tot_first](auto el){return std::abs(el.second) == div_mult_tot_first;})
)
{
return;
......
......@@ -391,7 +391,9 @@ std::vector<node_ptr> str2node::phi_from_file(const std::string filename, const
std::ifstream file_stream;
file_stream.open(filename, std::ios::in);
int numLines = 0;
int num_lines = 0;
int n_prim_feat = 0;
int n_invalid_feat = 0;
std::string line;
std::vector<node_ptr> phi;
......@@ -399,7 +401,7 @@ std::vector<node_ptr> str2node::phi_from_file(const std::string filename, const
while(std::getline(file_stream, line))
{
++numLines;
++num_lines;
if(line[0] == '#')
{
continue;
......@@ -408,18 +410,22 @@ std::vector<node_ptr> str2node::phi_from_file(const std::string filename, const
{
node_ptr feat = postfix2node(line, phi_0, feat_ind);
if(feat->type() == NODE_TYPE::FEAT)
{
++n_prim_feat;
continue;
}
phi.push_back(feat);
phi.back()->set_selected(false);
++feat_ind;
}
catch(const InvalidFeatureException& e)
{
++n_invalid_feat;
// Do Nothing
}
}
file_stream.close();
if(numLines < 1)
if(num_lines < 1)
{
throw std::logic_error("File, " + filename + " not present");
}
......
......@@ -231,6 +231,7 @@ void sisso::registerInputs()
.add_property("fix_intercept", &InputParser::fix_intercept, &InputParser::set_fix_intercept, "@DocString_inputs_fix_intercept@")
.add_property("global_param_opt", &InputParser::global_param_opt, &InputParser::set_global_param_opt, "@DocString_inputs_global_param_opt@")
.add_property("reparam_residual", &InputParser::reparam_residual, &InputParser::set_reparam_residual, "@DocString_inputs_reparam_residual@")
.add_property("phi_out_file", &InputParser::phi_out_file, &InputParser::set_phi_out_file, "@DocString_inputs_phi_out_file@")
;
}
......@@ -285,6 +286,7 @@ void sisso::feature_creation::registerFeatureSpace()
.def("feat_in_phi", &FeatureSpace::feat_in_phi, (arg("self"), arg("ind")), "@DocString_feat_space_feat_in_phi@")
.def("remove_feature", &FeatureSpace::remove_feature, (arg("self"), arg("ind")), "@DocString_feat_space_remove_feature@")
.def("get_feature", &FeatureSpace::get_feature, (arg("self"), arg("ind")), "@DocString_feat_space_get_feature@")
.def("output_phi", &FeatureSpace::output_phi, (arg("self")), "@DocString_feat_space_output_phi@")
.add_property("phi_selected", &FeatureSpace::phi_selected_py, "@DocString_feat_space_phi_selected_py@")
.add_property("phi0", &FeatureSpace::phi0_py, "@DocString_feat_space_phi0_py@")
.add_property("phi", &FeatureSpace::phi_py, "@DocString_feat_space_phi_py@")
......
......@@ -56,6 +56,7 @@ FeatureSpace::FeatureSpace(
mpi_reduce_op::set_op(_project_type, _cross_cor_max, _n_sis_select);
std::vector<node_ptr> phi_temp = str2node::phi_from_file(feature_file, _phi_0);
phi_temp.insert(phi_temp.begin(), _phi_0.begin(), _phi_0.end());
_n_feat = phi_temp.size();
......
# Number of Features: 3490
# Maximum Rung of the Calculation: 2
0
1
2
3
3|sp
2|abs
2|sin
2|cos
2|1|mult
2|1|div
2|3|div
3|0|mult
3|0|div
3|exp
3|inv
3|sq
3|cb
2|cbrt
3|cbrt
3|abs
3|sin
3|cos
3|1|mult
3|1|div
3|2|add
3|2|sub
3|2|abd
3|2|mult
3|2|div
1|cb
0|sq
0|cb
0|sp
0|cbrt
0|abs
0|1|div
0|2|div
0|3|div
1|0|mult
1|0|div
1|inv
1|sq
0|inv
1|sp
1|sqrt
1|cbrt
1|2|div
1|3|div
2|0|mult
2|0|div
2|inv
2|sq
2|cb
2|sp
0|3|div|cb
0|2|div|0|abs|mult
0|2|div|0|abs|div
0|2|div|1|sq|div
0|2|div|1|sp|div
0|2|div|1|sqrt|div
0|2|div|1|cbrt|div
0|2|div|2|sq|div
0|2|div|2|cb|div
0|3|div|0|add
0|3|div|0|sub
0|3|div|0|abd
0|3|div|0|mult
0|3|div|sq
0|2|div|0|abs|abd
0|3|div|sp
0|3|div|cbrt
0|3|div|abs
0|3|div|1|mult
0|3|div|1|div
0|3|div|2|mult
0|3|div|2|div
0|3|div|3|div
0|3|div|2|abs|mult
0|3|div|2|abs|div
0|3|div|2|sin|mult
0|3|div|2|sin|div
0|2|div|3|2|sub|mult
0|2|div|2|cbrt|div
0|2|div|3|cbrt|mult
0|2|div|3|cbrt|div
0|2|div|3|abs|mult
0|2|div|3|abs|div
0|2|div|3|sin|mult
0|2|div|3|sin|div
0|2|div|3|cos|mult
0|2|div|3|cos|div
0|2|div|3|1|mult|mult
0|2|div|3|1|mult|div
0|2|div|3|2|add|mult
0|2|div|3|2|add|div
0|3|div|2|cos|mult
0|2|div|3|2|sub|div
0|2|div|3|2|abd|mult
0|2|div|3|2|abd|div
0|2|div|3|2|mult|div
0|2|div|1|cb|mult
0|2|div|1|cb|div
0|2|div|0|sq|mult
0|2|div|0|cb|mult
0|2|div|0|sp|mult
0|2|div|0|cbrt|mult
0|2|div|0|abs|add
0|2|div|0|abs|sub
0|3|div|1|sp|div
0|3|div|0|sq|mult
0|3|div|0|cb|mult
0|3|div|0|sp|mult
0|3|div|0|cbrt|mult
0|3|div|0|abs|add
0|3|div|0|abs|sub
0|3|div|0|abs|abd
0|3|div|0|abs|mult
0|3|div|0|abs|div
0|3|div|0|2|div|add
0|3|div|0|2|div|sub
0|3|div|0|2|div|abd
0|3|div|1|sq|div
0|3|div|1|cb|div
0|3|div|1|sqrt|div
0|3|div|1|cbrt|div
0|3|div|2|sq|div
0|3|div|2|cb|div
1|0|mult|0|mult
1|0|mult|inv
1|0|mult|sq
1|0|mult|cb
1|0|mult|sp
1|0|mult|cbrt
1|0|mult|abs
1|0|mult|1|mult
0|3|div|3|sin|mult
0|3|div|2|cos|div
0|3|div|2|1|mult|mult
0|3|div|2|1|mult|div
0|3|div|3|0|mult|add
0|3|div|3|0|mult|sub
0|3|div|3|0|mult|abd
0|3|div|3|sq|div
0|3|div|3|cb|div
0|3|div|2|cbrt|mult
0|3|div|2|cbrt|div
0|3|div|3|cbrt|div
0|3|div|3|abs|mult
0|3|div|3|abs|div
0|2|div|3|cb|div
0|3|div|3|sin|div
0|3|div|3|cos|mult
0|3|div|3|cos|div
0|3|div|3|1|mult|div
0|3|div|3|2|add|mult
0|3|div|3|2|add|div
0|3|div|3|2|sub|mult
0|3|div|3|2|sub|div
0|3|div|3|2|abd|mult
0|3|div|3|2|abd|div
0|3|div|3|2|mult|div
0|3|div|1|cb|mult
0|1|div|3|0|mult|mult
0|1|div|1|div
0|1|div|2|mult
0|1|div|2|div
0|1|div|3|mult
0|1|div|3|div
0|1|div|3|sp|mult
0|1|div|2|abs|mult
0|1|div|2|abs|div
0|1|div|2|sin|mult
0|1|div|2|sin|div
0|1|div|2|cos|mult
0|1|div|2|cos|div
0|1|div|2|1|mult|div
0|1|div|abs
0|1|div|3|sq|mult
0|1|div|3|sq|div
0|1|div|3|cb|mult
0|1|div|3|cb|div
0|1|div|2|cbrt|mult
0|1|div|2|cbrt|div
0|1|div|3|cbrt|mult
0|1|div|3|cbrt|div
0|1|div|3|abs|mult
0|1|div|3|abs|div
0|1|div|3|sin|mult
0|1|div|3|sin|div
0|abs|1|0|mult|div
0|abs|3|2|abd|div
0|abs|3|2|mult|mult
0|abs|3|2|mult|div
0|abs|3|2|div|mult
0|abs|1|cb|mult
0|abs|1|cb|div
0|abs|0|sq|mult
0|abs|0|sq|div
0|abs|0|cb|mult
0|abs|0|cb|div
0|abs|0|sp|mult
0|abs|0|cbrt|mult
0|abs|0|cbrt|div
0|1|div|3|cos|mult
0|abs|1|sq|div
0|abs|1|sp|div
0|abs|1|sqrt|div
0|abs|1|cbrt|div
0|abs|2|0|mult|div
0|abs|2|sq|div
0|abs|2|cb|div
0|1|div|0|mult
0|1|div|sq
0|1|div|cb
0|1|div|sp
0|1|div|cbrt
0|2|div|2|abs|div
0|2|div|0|mult
0|2|div|sq
0|2|div|cb
0|2|div|sp
0|2|div|cbrt
0|2|div|abs
0|2|div|1|mult
0|2|div|1|div
0|2|div|2|div
0|2|div|3|mult
0|2|div|3|div
0|2|div|3|sp|mult
0|2|div|2|abs|mult
0|2|div|0|abd
0|2|div|2|sin|mult
0|2|div|2|sin|div
0|2|div|2|cos|mult
0|2|div|2|cos|div
0|2|div|2|1|mult|div
0|2|div|3|0|mult|add
0|2|div|3|0|mult|sub
0|2|div|3|0|mult|abd
0|2|div|3|0|mult|mult
0|2|div|3|sq|mult
0|2|div|3|sq|div
0|2|div|3|cb|mult
0|1|div|0|cb|mult
0|1|div|3|cos|div
0|1|div|3|1|mult|div
0|1|div|3|2|add|mult
0|1|div|3|2|add|div
0|1|div|3|2|sub|mult
0|1|div|3|2|sub|div
0|1|div|3|2|abd|mult
0|1|div|3|2|abd|div
0|1|div|3|2|mult|mult
0|1|div|3|2|mult|div
0|1|div|1|cb|div
0|1|div|0|sq|mult
1|0|mult|2|mult
0|1|div|0|sp|mult
0|1|div|0|cbrt|mult
0|1|div|0|abs|mult
0|1|div|0|abs|div
0|1|div|1|sq|div
0|1|div|1|sp|div
0|1|div|1|sqrt|div
0|1|div|1|cbrt|div
0|1|div|2|sq|div
0|1|div|2|cb|div
0|2|div|0|add
0|2|div|0|sub
1|sq|3|2|div|mult
1|sq|3|sin|mult
1|sq|3|sin|div
1|sq|3|cos|mult
1|sq|3|cos|div
1|sq|3|1|mult|mult
1|sq|3|2|add|mult
1|sq|3|2|add|div
1|sq|3|2|sub|mult
1|sq|3|2|sub|div
1|sq|3|2|abd|mult
1|sq|3|2|abd|div
1|sq|3|2|mult|mult
1|sq|3|2|mult|div
1|sq|3|abs|div
1|sq|0|sq|div
1|sq|0|cb|mult
1|sq|0|cb|div
1|sq|0|sp|mult
1|sq|0|cbrt|mult
1|sq|0|cbrt|div
1|sq|0|abs|mult
1|sq|0|abs|div
1|sq|0|2|div|mult
1|sq|0|3|div|mult
1|sq|1|0|mult|mult
1|sq|1|0|div|mult
1|sq|2|1|mult|mult
1|sq|inv
1|sq|sq
1|sq|2|mult
1|sq|2|div
1|sq|3|mult
1|sq|3|div
1|sq|3|sp|mult
1|sq|2|abs|mult
1|sq|2|abs|div
1|sq|2|sin|mult
1|sq|2|sin|div
1|sq|2|cos|mult
1|sq|2|cos|div
1|sq|2|0|mult|div
1|sq|2|3|div|mult
1|sq|3|0|mult|mult
1|sq|3|0|mult|div
1|sq|3|0|div|mult
1|sq|3|sq|div
1|sq|3|cb|mult
1|sq|3|cb|div
1|sq|2|cbrt|mult
1|sq|2|cbrt|div
1|sq|3|cbrt|mult
1|sq|3|cbrt|div
1|sq|3|abs|mult
1|sp|3|cos|div
1|sp|3|sq|mult
1|sp|3|sq|div
1|sp|3|cb|mult
1|sp|3|cb|div
1|sp|2|cbrt|mult
1|sp|2|cbrt|div
1|sp|3|cbrt|mult
1|sp|3|cbrt|div
1|sp|3|abs|mult
1|sp|3|abs|div
1|sp|3|sin|mult
1|sp|3|sin|div
1|sp|3|cos|mult
1|sp|3|0|div|mult
1|sp|3|1|mult|mult
1|sp|3|2|add|mult
1|sp|3|2|add|div
1|sp|3|2|sub|mult
1|sp|3|2|sub|div
1|sp|3|2|abd|mult
1|sp|3|2|abd|div
1|sp|3|2|mult|mult
1|sp|3|2|mult|div
1|sp|3|2|div|mult
1|sp|0|sq|mult
1|sp|0|sq|div
1|sp|3|mult
1|sq|2|sq|div
1|sq|2|cb|div
0|inv|abs
0|inv|3|0|div|add
0|inv|3|0|div|sub
0|inv|3|0|div|abd
1|sp|0|mult
1|sp|0|div
1|sp|inv
1|sp|sq
1|sp|cb
1|sp|2|mult
1|sp|2|div
1|sq|0|div
1|sp|3|div
1|sp|3|sp|div
1|sp|2|abs|mult
1|sp|2|abs|div
1|sp|2|sin|mult
1|sp|2|sin|div
1|sp|2|cos|mult
1|sp|2|cos|div
1|sp|2|1|mult|mult
1|sp|2|3|div|mult
1|sp|3|0|mult|mult
1|sp|3|0|mult|div
1|0|mult|0|cb|mult
1|0|mult|3|cos|div
1|0|mult|3|1|mult|mult
1|0|mult|3|2|add|mult
1|0|mult|3|2|add|div
1|0|mult|3|2|sub|mult
1|0|mult|3|2|sub|div
1|0|mult|3|2|abd|mult
1|0|mult|3|2|abd|div
1|0|mult|3|2|mult|mult
1|0|mult|3|2|mult|div
1|0|mult|3|2|div|mult
1|0|mult|1|cb|mult
1|0|mult|0|sq|mult
1|0|mult|3|cos|mult
1|0|mult|0|sp|mult
1|0|mult|0|cbrt|mult
1|0|mult|0|abs|mult
1|0|mult|0|abs|div
1|0|mult|0|2|div|mult
1|0|mult|0|3|div|mult
1|0|mult|2|sq|div
1|0|mult|2|cb|div
1|0|div|0|div
1|0|div|sq
1|0|div|cb
1|0|div|sp
1|0|mult|3|0|mult|mult
1|0|mult|2|div
1|0|mult|3|mult
1|0|mult|3|div
1|0|mult|3|sp|mult
1|0|mult|3|sp|div
1|0|mult|2|abs|mult
1|0|mult|2|abs|div
1|0|mult|2|sin|mult
1|0|mult|2|sin|div
1|0|mult|2|cos|mult
1|0|mult|2|cos|div
1|0|mult|2|1|mult|mult
1|0|mult|2|3|div|mult
1|0|div|cbrt
1|0|mult|3|sq|mult
1|0|mult|3|sq|div
1|0|mult|3|cb|mult
1|0|mult|3|cb|div
1|0|mult|2|cbrt|mult
1|0|mult|2|cbrt|div
1|0|mult|3|cbrt|mult
1|0|mult|3|cbrt|div
1|0|mult|3|abs|mult
1|0|mult|3|abs|div
1|0|mult|3|sin|mult
1|0|mult|3|sin|div
1|0|div|0|sq|div
1|0|div|3|sin|div
1|0|div|3|cos|mult
1|0|div|3|cos|div
1|0|div|3|1|mult|mult
1|0|div|3|2|add|mult
1|0|div|3|2|add|div
1|0|div|3|2|sub|mult
1|0|div|3|2|sub|div
1|0|div|3|2|abd|mult
1|0|div|3|2|abd|div
1|0|div|3|2|mult|mult
1|0|div|3|2|mult|div
1|0|div|1|cb|mult
1|0|div|3|sin|mult
1|0|div|0|cb|div
1|0|div|0|cbrt|div
1|0|div|0|abs|mult
1|0|div|0|abs|div
1|0|div|2|0|mult|div
1|0|div|2|sq|div
1|inv|2|1|div|add
1|inv|2|1|div|sub
1|inv|2|1|div|abd
1|inv|3|1|div|add
1|inv|3|1|div|sub
1|sq|0|mult
1|0|div|2|cos|div
1|0|div|abs
1|0|div|1|mult
1|0|div|2|mult
1|0|div|2|div
1|0|div|3|mult
1|0|div|3|div
1|0|div|3|sp|mult
1|0|div|2|abs|mult
1|0|div|2|abs|div
1|0|div|2|sin|mult
1|0|div|2|sin|div
1|0|div|2|cos|mult
0|abs|3|2|abd|mult
1|0|div|2|1|mult|mult
1|0|div|3|0|mult|div
1|0|div|3|sq|mult
1|0|div|3|sq|div
1|0|div|3|cb|mult
1|0|div|3|cb|div
1|0|div|2|cbrt|mult
1|0|div|2|cbrt|div
1|0|div|3|cbrt|mult
1|0|div|3|cbrt|div
1|0|div|3|abs|mult
1|0|div|3|abs|div
0|sq|inv
1|cb|3|2|abd|mult
1|cb|3|2|abd|div
1|cb|3|2|mult|mult
1|cb|3|2|mult|div
1|cb|3|2|div|mult
1|cb|0|sq|div
1|cb|0|cb|div
1|cb|0|sp|div
1|cb|0|cbrt|div
1|cb|0|abs|div
1|cb|2|0|mult|div
1|cb|2|sq|div
1|cb|2|cb|div