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

prediction with manual range selection

parent 53510d15
No related branches found
No related tags found
No related merge requests found
...@@ -137,8 +137,9 @@ with c1: ...@@ -137,8 +137,9 @@ with c1:
x_block.columns = x_block.columns.astype(str) x_block.columns = x_block.columns.astype(str)
yname = system_data['data']['target'].name yname = system_data['data']['target'].name
st.info("Loaded model to predict " + yname) st.info("Loaded model to predict " + yname)
if ObjectHash(current=None, add=list(system_data['predictors_'])) == ObjectHash(current=None, add=list(x_block.columns)): shared_elements = set(system_data['predictors_']).intersection(x_block.columns)
pred_data = x_block if len(shared_elements)==len(system_data['predictors_']):
pred_data = x_block.loc[:,system_data['predictors_']]
else: else:
st.error( st.error(
'The names of the features (columns) in the training set and the prediction set are not identical. Thus, prediction cannot be performed.') 'The names of the features (columns) in the training set and the prediction set are not identical. Thus, prediction cannot be performed.')
...@@ -237,13 +238,11 @@ if not preprocessed.empty: ...@@ -237,13 +238,11 @@ if not preprocessed.empty:
st.session_state['predict'] = True st.session_state['predict'] = True
if not preprocessed.empty and st.session_state['predict']: if not preprocessed.empty and st.session_state['predict']:
c4, c5 = st.columns([2, 1]) model = system_data['model_']
with c5: if system_data['model_type'] in ['PLS', 'TPE-iPLS']:
model = system_data['model_'] nvar = system_data['model_'].n_features_in_
if system_data['model_type'] in ['PLS', 'TPE-iPLS']: elif system_data['model_type'] == 'LW-PLS':
nvar = system_data['model_'].n_features_in_ nvar = system_data['data']['raw-spectra'].shape[1]
elif system_data['model_type'] == 'LW-PLS':
nvar = system_data['data']['raw-spectra'].shape[1]
if system_data['selected-wls'] is None: if system_data['selected-wls'] is None:
preprocesseddf = preprocessed preprocesseddf = preprocessed
...@@ -317,11 +316,12 @@ if not preprocessed.empty: ...@@ -317,11 +316,12 @@ if not preprocessed.empty:
################################### results display ################################### ################################### results display ###################################
if not result.empty: if not result.empty:
c4, c5 = st.columns([2, 1])
hist = pred_hist(pred=result) hist = pred_hist(pred=result)
with c4: with c4:
st.write('Predicted values distribution') st.write('Predicted values distribution')
st.pyplot(hist) st.pyplot(hist)
st.write('Predicted values table') st.write('Table of predicted values')
resultT = result.reset_index() resultT = result.reset_index()
st.dataframe(resultT.T) st.dataframe(resultT.T)
with c5: with c5:
......
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