Commit 4ae79049 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Add input marker to set data file relative to sisso.json file name

used for make test
parent 920984d9
...@@ -45,6 +45,7 @@ InputParser::InputParser() : ...@@ -45,6 +45,7 @@ InputParser::InputParser() :
_n_models_store(1), _n_models_store(1),
_max_param_depth(-1), _max_param_depth(-1),
_nlopt_seed(42), _nlopt_seed(42),
_data_file_relative_to_json(false),
_fix_intercept(false), _fix_intercept(false),
_global_param_opt(false), _global_param_opt(false),
_reparam_residual(false) _reparam_residual(false)
...@@ -79,10 +80,21 @@ InputParser::InputParser(pt::ptree ip, std::string fn, std::shared_ptr<MPI_Inter ...@@ -79,10 +80,21 @@ InputParser::InputParser(pt::ptree ip, std::string fn, std::shared_ptr<MPI_Inter
_n_models_store(ip.get<int>("n_models_store", _n_residual)), _n_models_store(ip.get<int>("n_models_store", _n_residual)),
_max_param_depth(ip.get<int>("max_feat_param_depth", _max_rung)), _max_param_depth(ip.get<int>("max_feat_param_depth", _max_rung)),
_nlopt_seed(ip.get<int>("nlopt_seed", 42)), _nlopt_seed(ip.get<int>("nlopt_seed", 42)),
_data_file_relative_to_json(ip.get<bool>("data_file_relatice_to_json", false)),
_fix_intercept(ip.get<bool>("fix_intercept", false)), _fix_intercept(ip.get<bool>("fix_intercept", false)),
_global_param_opt(ip.get<bool>("global_param_opt", false)), _global_param_opt(ip.get<bool>("global_param_opt", false)),
_reparam_residual(ip.get<bool>("reparam_residual", false)) _reparam_residual(ip.get<bool>("reparam_residual", false))
{ {
if(_data_file_relative_to_json)
{
if((_data_file[0] == '/') || (_data_file[0] == '\\'))
{
throw std::logic_error("The data file is an absolute path, but _data_file_relative_to_json is true.");
}
std::vector<std::string> filepath = str_utils::split_string_trim(fn, "/");
_data_file = str_utils::join("/", filepath.data(), filepath.size() - 1) + "/" + _data_file;
}
// Check if param ops are passed without being build with parameterized features // Check if param ops are passed without being build with parameterized features
#ifndef PARAMETERIZE #ifndef PARAMETERIZE
if(_allowed_param_ops.size() > 0) if(_allowed_param_ops.size() > 0)
...@@ -806,7 +818,8 @@ void InputParser::set_phi_0(std::vector<FeatureNode> phi_0) ...@@ -806,7 +818,8 @@ void InputParser::set_phi_0(std::vector<FeatureNode> phi_0)
void strip_comments(std::string& filename) void strip_comments(std::string& filename)
{ {
//Open input and output file //Open input and output file
std::string newfn = "stripped_" + filename; std::vector<std::string> filepath = str_utils::split_string_trim(filename, "/");
std::string newfn = str_utils::join("/", filepath.data(), filepath.size() - 1) + "/stripped_" + filepath.back();
std::fstream inputfile; std::fstream inputfile;
inputfile.open(filename); inputfile.open(filename);
std::ofstream inputcopy; std::ofstream inputcopy;
...@@ -846,7 +859,8 @@ pt::ptree get_prop_tree(std::string fn, std::shared_ptr<MPI_Interface> mpi_comm) ...@@ -846,7 +859,8 @@ pt::ptree get_prop_tree(std::string fn, std::shared_ptr<MPI_Interface> mpi_comm)
} }
else else
{ {
fn = "stripped_" + fn; std::vector<std::string> filepath = str_utils::split_string_trim(fn, "/");
fn = str_utils::join("/", filepath.data(), filepath.size() - 1) + "/stripped_" + filepath.back();
} }
mpi_comm->barrier(); mpi_comm->barrier();
......
...@@ -104,6 +104,7 @@ private: ...@@ -104,6 +104,7 @@ private:
int _nlopt_seed; //!< The seed used for the nlOpt library int _nlopt_seed; //!< The seed used for the nlOpt library
bool _fix_intercept; //!< If true the bias term is fixed at 0 bool _fix_intercept; //!< If true the bias term is fixed at 0
bool _data_file_relative_to_json; //!< If true then the data filepath is relative to the filename path
bool _global_param_opt; //!< True if global optimization is requested for non-linear optimization of parameters (Can break reproducibility) bool _global_param_opt; //!< True if global optimization is requested for non-linear optimization of parameters (Can break reproducibility)
bool _reparam_residual; //!< If True then reparameterize features using the residuals of each model bool _reparam_residual; //!< If True then reparameterize features using the residuals of each model
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 1, "max_rung": 1,
"n_residual": 1, "n_residual": 1,
"data_file": "data.csv", "data_file": "data.csv",
"data_file_relatice_to_json": true,
"property_key": "prop", "property_key": "prop",
"leave_out_frac": 0.2, "leave_out_frac": 0.2,
"n_models_store": 1, "n_models_store": 1,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 2, "max_rung": 2,
"n_residual": 1, "n_residual": 1,
"data_file": "../data.csv", "data_file": "../data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"task_key": "Task", "task_key": "Task",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 2, "max_rung": 2,
"n_residual": 1, "n_residual": 1,
"data_file": "../data.csv", "data_file": "../data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"task_key": "Task", "task_key": "Task",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 1, "max_rung": 1,
"n_residual": 1, "n_residual": 1,
"data_file": "data.csv", "data_file": "data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
"n_models_store": 1, "n_models_store": 1,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 2, "max_rung": 2,
"n_residual": 1, "n_residual": 1,
"data_file": "../data.csv", "data_file": "../data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"task_key": "Task", "task_key": "Task",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
......
from sissopp import ModelRegressor
from pathlib import Path
import numpy as np
model = ModelRegressor(
str("models/train_dim_2_model_0.dat")
)
assert model.rmse < 1e-4
{
"desc_dim": 2,
"n_sis_select": 1,
"max_rung": 2,
"n_residual": 1,
"data_file": "../data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop",
"task_key": "Task",
"leave_out_frac": 0.00,
"n_models_store": 1,
"opset": ["add", "sub", "abs_diff", "mult", "div", "inv", "abs", "exp", "log", "sin", "cos", "sq", "cb", "six_pow", "sqrt", "cbrt", "neg_exp"],
"fix_intercept": false
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 2, "max_rung": 2,
"n_residual": 1, "n_residual": 1,
"data_file": "data.csv", "data_file": "data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"task_key": "Task", "task_key": "Task",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"max_rung": 1, "max_rung": 1,
"n_residual": 1, "n_residual": 1,
"data_file": "data.csv", "data_file": "data.csv",
"data_file_relatice_to_json": true,
"property_key": "Prop", "property_key": "Prop",
"leave_out_frac": 0.05, "leave_out_frac": 0.05,
"n_rung_generate": 1, "n_rung_generate": 1,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment