diff --git a/src/pages/1-samples_selection.py b/src/pages/1-samples_selection.py index ae1392387470d5b8c2b689208282dcf7602820c7..60799efaa985d74536efd5d952124c93d66e70c0 100644 --- a/src/pages/1-samples_selection.py +++ b/src/pages/1-samples_selection.py @@ -64,7 +64,7 @@ match st.session_state["interface"]: delete_files(keep = ['.py', '.pyc','.bib']) # ####################################### page preamble ####################################### -st.title("Calibration Subset Selection") # page title +st.header("Calibration Subset Selection") # page title st.markdown("Create a predictive model, then use it for predicting your target variable (chemical data) from NIRS spectra") c1, c2 = st.columns([3, 1]) c1.image("./images/sample selection.png", use_column_width=True) # graphical abstract @@ -172,7 +172,7 @@ else: # fig.savefig("./report/figures/spectra_plot.png", dpi=400) ## Export report ################################################### BEGIN : visualize and split the data #################################################### -st.header("I - Spectral Data Visualization", divider='blue') +st.subheader("I - Spectral Data Visualization", divider='blue') if not spectra.empty: p_hash(np.mean(spectra)) n_samples = spectra.shape[0] @@ -233,7 +233,7 @@ if not spectra.empty: ################################################### END : visualize and split the data #################################################### ############################## Exploratory data analysis ############################### -st.header("II - Exploratory Data Analysis-Multivariable Data Analysis", divider='blue') +st.subheader("II - Exploratory Data Analysis-Multivariable Data Analysis", divider='blue') ###### 1- Dimensionality reduction ###### t = DataFrame # scores @@ -401,6 +401,9 @@ if not t.empty: with c12: st.write('Scores plot') tcr_plot = tcr.copy() + if len(axis)== 1: + tcr_plot['1d'] = np.random.uniform(-.5, .5, tcr_plot.shape[0]) + colfilter = st.selectbox('Color by:', options= filter,format_func = lambda x: x if x else "<Select>") p_hash(colfilter) if colfilter in cluster_methods: @@ -431,10 +434,12 @@ if not t.empty: mode ='markers', marker = dict(size = 5, color = 'black'), name = 'selected samples') - case 1: - fig = px.scatter(tcr_plot, x = axis[0], y = [0]*tcr_plot.shape[0], color = col_var_name ,color_discrete_sequence = custom_color_palette) - fig.add_scatter(x = t_selected.loc[:,axis[0]], y = [0]*tcr_plot.shape[0], + case 1: + yy = np.random.uniform(-.5, .5, tcr_plot.shape[0]) + fig = px.scatter(tcr_plot, x = axis[0], y = '1d', color = col_var_name ,color_discrete_sequence = custom_color_palette) + fig.add_scatter(x = t_selected.loc[:,axis[0]], y = t_selected['1d'], mode ='markers', marker = dict(size = 5, color = 'black'), name = 'selected samples') + fig.update_layout( yaxis_range=[-1.6, 1.6]) fig.update_yaxes(visible=False) st.plotly_chart(fig, use_container_width = True) @@ -575,7 +580,6 @@ if not spectra.empty: fcri = sc.stats.f.isf(0.05, 3, n_samples) tresh0 = (3 * (n_samples ** 2 - 1) * fcri) / (n_samples * (n_samples - 3)) tresh1 = sc.stats.chi2.ppf(0.05, df = 3) - hotelling_plot = px.scatter(t, x = hotelling, y = residuals, color=labels if list(labels) else None, color_discrete_sequence= custom_color_palette) hotelling_plot.add_scatter(x = hotelling[selected_samples_idx] , y = residuals[selected_samples_idx], @@ -610,7 +614,7 @@ if not spectra.empty: font= dict(color= "black", size= 35), bgcolor ='white', borderpad= 2, bordercolor= 'black', borderwidth= 3) # hotelling_plot.write_image("./report/out/figures/hotelling_plot.png", format="png") -st.header('III - Selected Samples for Reference Analysis', divider='blue') +st.subheader('III - Selected Samples for Reference Analysis', divider='blue') if labels: c16, c17 = st.columns([3, 1]) c16.write("Tabular identifiers of selected samples for reference analysis:") @@ -657,7 +661,7 @@ if not sam.empty: zip_data = "" Nb_ech = str(n_samples) nb_clu = str(sam1.shape[0]) - st.header('Download the analysis results') + st.subheader('Download the analysis results') st.write("**Note:** Please check the box only after you have finished processing your data and are satisfied with the results. Checking the box prematurely may slow down the app and could lead to crashes.") decis = st.checkbox("Yes, I want to download the results") if decis: diff --git a/src/pages/2-model_creation.py b/src/pages/2-model_creation.py index 06b055489651890ed7c0361a113464e70f694c18..52672662e7b0ad668d30762082da81d73a9c5476 100644 --- a/src/pages/2-model_creation.py +++ b/src/pages/2-model_creation.py @@ -41,12 +41,12 @@ class lw: ################ clean the results dir ############# delete_files(keep = ['.py', '.pyc','.bib']) -dirpath = Path('report/out/model') -if not dirpath.exists(): - os.mkdir(path = dirpath) - +for i in ['model', 'dataset', 'figures']: + dirpath = Path('./report/out/')/i + if not dirpath.exists(): + dirpath.mkdir(parents=True, exist_ok=True) # ####################################### page preamble ####################################### -st.title("Calibration Model Development") # page title +st.header("Calibration Model Development") # page title st.markdown("Create a predictive model, then use it for predicting your target variable (chemical data) from NIRS spectra") c0, c1 = st.columns([1, .4]) c0.image("./images/model_creation.png", use_column_width = True) # graphical abstract @@ -192,7 +192,7 @@ match file: ################################################### BEGIN : visualize and split the data #################################################### -st.header("I - Data visualization", divider = 'blue') +st.subheader("I - Data visualization", divider = 'blue') if not spectra.empty and not y.empty: p_hash(y) p_hash(np.mean(spectra)) @@ -237,7 +237,7 @@ model_type = None # initialize the selected regression algorithm Reg = None # initialize the regression model object # intervalls_with_cols = DataFrame() -st.header("II - Model creation", divider = 'blue') +st.subheader("II - Model creation", divider = 'blue') if not spectra.empty and not y.empty: c4, c5, c6 = st.columns([1, 1, 3]) with c4: @@ -513,7 +513,7 @@ if Reg: # Display CV results numbers_dict = {1: "One", 2: "Two",3: "Three",4: "Four",5: "Five", 6: "Six",7: "Seven",8: "Eight",9: "Nine",10: "Ten"} - st.header(f" {numbers_dict[nb_folds]}-Fold Cross-Validation results") + st.subheader(f" {numbers_dict[nb_folds]}-Fold Cross-Validation results") @st.cache_data(show_spinner =False) def cv_display(change): @@ -544,7 +544,7 @@ if Reg: ################################################### BEGIN : Model Diagnosis #################################################### -st.header("III - Model Diagnosis", divider='blue') +st.subheader("III - Model Diagnosis", divider='blue') if Reg: # signal preprocessing results preparation for latex report prep_para = Reg.best_hyperparams_.copy() diff --git a/src/pages/3-prediction.py b/src/pages/3-prediction.py index 3dce23aa31c446be0a257f81863e60a16fb0fafd..545508385ebd712f6773d2b632bc3e7c567c2279 100644 --- a/src/pages/3-prediction.py +++ b/src/pages/3-prediction.py @@ -37,7 +37,7 @@ def delete_files(keep): os.remove(os.path.join(root, file)) ################################################################### -st.title("Prediction making using a previously developed model") +st.header("Prediction making using a previously developed model") c1, c2 = st.columns([2, 1]) c1.image("./images/prediction making.png", use_column_width=True) pred_data = DataFrame @@ -153,7 +153,7 @@ with c2: # Load parameters -st.header("I - Spectral data preprocessing & visualization", divider='blue') +st.subheader("I - Spectral data preprocessing & visualization", divider='blue') # try: if not pred_data.empty:# Load the model with joblib @st.cache_data @@ -207,7 +207,7 @@ if not pred_data.empty:# Load the model with joblib st.info('The spectra were preprocessed using:\n'+SG+"\n"+Norm) ################### Predictions making ########################## - st.header("II - Prediction making", divider='blue') + st.subheader("II - Prediction making", divider='blue') disable2 = False if check_exist("pred_data") else True pred_button = st.button('Predict', type='primary', disabled= disable2, use_container_width=False) diff --git a/src/pages/4-inputs.py b/src/pages/4-inputs.py index dea19c2bac39f5b9bf81b305d8d9e7aae4050fd9..21f66863716c1b1585c106ddfa94a070a896536e 100644 --- a/src/pages/4-inputs.py +++ b/src/pages/4-inputs.py @@ -21,7 +21,7 @@ if 'form_submitted' not in st.session_state: with st.container(): # Text input fields - st.header("Complete and save the following form with the data context:",divider="blue") + st.subheader("Complete and save the following form with the data context:",divider="blue") st.warning('Make sure that the form is well completed, because the reliability of the results depends mainly on it !', icon="⚠️") with st.form(key = 'my_form'): diff --git a/src/style/header.py b/src/style/header.py index 577d9558b5675626b84ef4f37ea4626ab98062cc..799e2ee5df43815cf072ca0b6baf84f180b08cdd 100644 --- a/src/style/header.py +++ b/src/style/header.py @@ -2,22 +2,12 @@ from Packages import * def add_header(): st.markdown( """ - <div style="width: 100%;height: 170px; background-color: rgb(0,0,0,0);border: 4px solid rgb(122,176,199); padding: 0px; margin-bottom: 10px;border-radius: 20%; "> - <h1 style="font-family: 'Arial',d;text-align: center; color: #39bf55;">PACE - MEEB / CEFE</h1> - <h2 style="font-family: 'Arial';text-align: center; color: #2cb048;">NIRS Utils</h2> + <div style="width: 100%;height: 130px;background-color: rgb(0,0,0,0);border: 4px solid rgb(122,176,199);padding: 1px;margin-bottom: 0px;border-radius: 20%; "> + <h2 style="font-family: 'Arial',d; text-align: center;color: #39bf55;">PACE - MEEB / CEFE</h1> + <h3 style="font-family: 'Arial';text-align: center; color: #2cb048;">NIRS Utils</h2> </div> - """, - unsafe_allow_html=True, - ) - - st.markdown(""" <style> - .block-container { - padding-top: 3rem; - padding-bottom: 0rem; - padding-left: 5rem; - padding-right: 5rem; - } + .block-container {padding-top: 3rem;padding-bottom: 0rem;padding-left: 5rem;padding-right: 5rem;} </style> """, unsafe_allow_html=True)