Skip to content
Snippets Groups Projects
Commit 28813755 authored by DIANE's avatar DIANE
Browse files

model creation

parent c35aebcb
No related branches found
No related tags found
No related merge requests found
...@@ -257,6 +257,9 @@ if not x_block.empty and not y.empty: ...@@ -257,6 +257,9 @@ if not x_block.empty and not y.empty:
from utils.miscellaneous import data_split from utils.miscellaneous import data_split
X_train, X_test, y_train, y_test, train_index, test_index = data_split( X_train, X_test, y_train, y_test, train_index, test_index = data_split(
x=x_block, y=y) x=x_block, y=y)
import functools
train_pos = functools.reduce(lambda acc, x: acc + [list(x_block.index).index(x)], list(train_index), [])
test_pos = functools.reduce(lambda acc, x: acc + [list(x_block.index).index(x)], list(test_index), [])
with c3: with c3:
st.write('Loaded data summary') st.write('Loaded data summary')
...@@ -471,9 +474,6 @@ if not x_block.empty and not y.empty: ...@@ -471,9 +474,6 @@ if not x_block.empty and not y.empty:
Model = None Model = None
st.info( st.info(
'Info: Choose a modelling algorithm from the dropdown list!') 'Info: Choose a modelling algorithm from the dropdown list!')
import pickle
with open('star.pkl', "wb") as f:
pickle.dump(Model, f)
return Model return Model
c7, c8 = st.columns([2, 2]) c7, c8 = st.columns([2, 2])
...@@ -739,12 +739,12 @@ if model: ...@@ -739,12 +739,12 @@ if model:
imp_fig.savefig(res_path / "figures/vipscores.png") imp_fig.savefig(res_path / "figures/vipscores.png")
# pickle the results # pickle the results
pklfile = {'data': {'raw-spectra': x_block, 'target': y, 'training_data_idx': train_index, 'testing_data_idx': test_index}, pklfile = {'data': {'raw-spectra': x_block, 'target': y, 'training_data_idx': train_pos, 'testing_data_idx': test_pos},
'spec-preprocessing': {"normalization": modelling.best_hyperparams_['normalization'], 'SavGol(polyorder,window_length,deriv)': [modelling.best_hyperparams_["polyorder"], 'spec-preprocessing': {"normalization": modelling.best_hyperparams_['normalization'], 'SavGol(polyorder,window_length,deriv)': [modelling.best_hyperparams_["polyorder"],
modelling.best_hyperparams_[ modelling.best_hyperparams_[
'window_length'], 'window_length'],
modelling.best_hyperparams_['deriv']]}, modelling.best_hyperparams_['deriv']]},
"model_type": model_type, 'model_': modelling.model_, 'predictors_': predictors if model_type == 'TPE-iPLS' else list(x_block.columns)} "model_type": model_type, 'model_': modelling.model_, 'predictors_': list(x_block.columns), 'selected-wls': predictors if model_type == 'TPE-iPLS' else None}
with open(res_path / 'file_system.pkl', "wb") as pkl: with open(res_path / 'file_system.pkl', "wb") as pkl:
dump(pklfile, pkl) dump(pklfile, pkl)
...@@ -776,7 +776,7 @@ if model: ...@@ -776,7 +776,7 @@ if model:
# def preparing_results_for_downloading(change): # def preparing_results_for_downloading(change):
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
pklfile = {'model_': modelling.model_, "model_type": model_type, 'data': {'raw-spectra': x_block, 'target': y, 'training_data_idx': train_index, 'testing_data_idx': test_index}, pklfile = {'model_': modelling.model_, "model_type": model_type, 'data': {'raw-spectra': x_block, 'target': y, 'training_data_idx': train_pos, 'testing_data_idx': test_pos},
'spec-preprocessing': {"normalization": modelling.best_hyperparams_['normalization'], 'SavGol(polyorder,window_length,deriv)': [modelling.best_hyperparams_["polyorder"], 'spec-preprocessing': {"normalization": modelling.best_hyperparams_['normalization'], 'SavGol(polyorder,window_length,deriv)': [modelling.best_hyperparams_["polyorder"],
modelling.best_hyperparams_[ modelling.best_hyperparams_[
'window_length'], 'window_length'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment