diff --git a/src/Report/report.py b/src/Report/report.py index 4a0b309ae62b78f29e6dafa4fd95146926e648ab..9dc48ee30beefb0d790f28b5133be6c08260cbe4 100644 --- a/src/Report/report.py +++ b/src/Report/report.py @@ -340,9 +340,16 @@ def report(*args): \label{fig:importance} \end{figure} """ - - elif "LW-PLS " in to_report: - """""" + elif "LW-PLS" in to_report: + latex_report += r"""The average of raw and preprocessed spectra is visualized in \cref{fig:importance}. \par + + \begin{figure}[h] + \centering + \includegraphics[width=1\linewidth]{Variable_importance.png} + \caption{Visualizing the average spectrum computed for raw and preprocessed spectra} + \label{fig:importance} + \end{figure} + """ elif "TPE-iPLS" in to_report: latex_report += r""" Many research papers have proved that interval selection methods, with different number of intervalls, helps reduce noise and model overfitting, diff --git a/src/pages/2-model_creation.py b/src/pages/2-model_creation.py index 01890edfc0c5fedd345e1ef0f809d700ff188f93..06d064587b935027ab3d0a120eb5dd84f05210f6 100644 --- a/src/pages/2-model_creation.py +++ b/src/pages/2-model_creation.py @@ -186,8 +186,8 @@ if not spectra.empty and not y.empty: #M2.dataframe(Pin.pred_data_) elif regression_algo == reg_algo[2]: - M1.write('KFold for Cross-Validation = ' + str(nb_folds)) - info = M1.info('Starting LWPLSR model creation... Please wait a few minutes.') + M20.write(f'K-Fold for Cross-Validation (K = {str(nb_folds)})') + info = M20.info('Starting LWPLSR model creation... Please wait a few minutes.') # export data to csv for Julia train/test data_to_work_with = ['x_train_np', 'y_train_np', 'x_test_np', 'y_test_np'] x_train_np, y_train_np, x_test_np, y_test_np = X_train.to_numpy(), y_train.to_numpy(), X_test.to_numpy(), y_test.to_numpy() @@ -260,14 +260,15 @@ if not spectra.empty and not y.empty: ## plots Reg.cv_data_ = KF_CV().meas_pred_eq(y = np.array(y_train), ypcv= Reg.cv_data_['YpredCV'], folds=folds) Reg.pretreated_spectra_ = preReg.pretreated_spectra_ + Reg.best_hyperparams_print = {**preReg.best_hyperparams_, **Reg.best_hyperparams_} Reg.best_hyperparams_ = {**preReg.best_hyperparams_, **Reg.best_hyperparams_} info.empty() - M1.success('Model created!') + M20.success('Model created!') except FileNotFoundError as e: # Display error message on the interface if modeling is wrong info.empty() - M1.warning('- ERROR during model creation -') + M20.warning('- ERROR during model creation -') Reg = None for i in data_to_work_with: os.unlink(temp_path / str(i + ".csv")) @@ -481,8 +482,8 @@ if not spectra.empty and not y.empty and regression_algo: if regression_algo in reg_algo[1:] and Reg is not None: fig, (ax1, ax2) = plt.subplots(2,1, figsize = (12, 4), sharex=True) ax1.plot(colnames, np.mean(X_train, axis = 0), color = 'black', label = 'Average spectrum (Raw)') - if regression_algo != reg_algo[2]: - ax2.plot(colnames, np.mean(Reg.pretreated_spectra_ , axis = 0), color = 'black', label = 'Average spectrum (pretreated)') + # if regression_algo != reg_algo[2]: + ax2.plot(colnames, np.mean(Reg.pretreated_spectra_ , axis = 0), color = 'black', label = 'Average spectrum (Pretreated)') ax2.set_xlabel('Wavelenghts') plt.tight_layout()