import numpy as np from pathlib import Path import json from LWPLSR_ import LWPLSR # loading the lwplsr_inputs.json temp_path = Path("temp/") for i in ['x_train_np', 'y_train_np', 'x_test_np', 'y_test_np']: globals()[i] = np.genfromtxt(temp_path / str(i + ".csv"), delimiter=',') print('CSV imported') print('start model creation') Reg = LWPLSR(x_train_np, y_train_np, x_test_np, y_test_np) print('model created. \n now fit') LWPLSR.Jchemo_lwplsr_fit(Reg) print('now predict') LWPLSR.Jchemo_lwplsr_predict(Reg) json_export = {} data_to_export = ['model', 'pred_data', 'metrics'] json_export['pred_data_train'] = Reg.pred_data_[0].to_dict() json_export['pred_data_cv'] = Reg.pred_data_[1].to_dict() json_export['pred_data_test'] = Reg.pred_data_[2].to_dict() json_export['metrics'] = Reg.metrics_.to_dict() json_export['model'] = str(Reg.model_) with open(temp_path / "lwplsr_outputs.json", "w+") as outfile: json.dump(json_export, outfile) print(Reg.metrics_)