From fde1c5821b26b99172e8d351096c55d9d3a1c30c Mon Sep 17 00:00:00 2001 From: DIANE <abderrahim.diane@cefe.cnrs.fr> Date: Fri, 30 Aug 2024 15:58:47 +0200 Subject: [PATCH] corrections --- src/Report/report.py | 38 +++++++++++----------- src/pages/1-samples_selection.py | 1 + src/pages/3-prediction.py | 4 +-- src/pages/4-inputs.py | 55 ++++++++++++++++---------------- 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/Report/report.py b/src/Report/report.py index c6443a3..ec88761 100644 --- a/src/Report/report.py +++ b/src/Report/report.py @@ -11,21 +11,21 @@ def intersect(l1, l2): def check(file): return os.path.isfile(file) def report(*args): - signal_preprocess = {'Snv':'Standard Normal Variate (SNV) \cite{barnes1989standard}', - 'SG': 'Savitzky-Golay (SG) \cite{savitzky1964smoothing}'} - dim_red_methods= {'PCA':'Principal Components Analysis (PCA) \cite{wold1987principal,ringner2008principal,greenacre2022principal,JMLR:v12:pedregosa11a}', - 'UMAP':'Uniform Manifold Approximation and Projection (UMAP) \cite{ghojogh2021uniform,JMLR:v12:pedregosa11a}', - 'NMF':'Non-negative Matrix Factorization (NMF) \cite{lopes2015non}'} # List of dimensionality reduction algos - cluster_methods = {'Kmeans':'Kmeans \cite{chong2021k,JMLR:v12:pedregosa11a}', - 'HDBSCAN':'Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN) \cite{mcinnes2017hdbscan}', - 'AP':'Affinity Propagation (AP) \cite{dueck2009affinity,JMLR:v12:pedregosa11a}', - 'KS':'Kennard-Stone algorithm (KS)', - 'RDM': 'random approach'} # List of clustering algos + signal_preprocess = {'Snv':r'''Standard Normal Variate (SNV) \cite{barnes1989standard}''', + 'SG': r'''Savitzky-Golay (SG) \cite{savitzky1964smoothing}'''} + dim_red_methods= {'PCA':r'''Principal Components Analysis (PCA) \cite{wold1987principal,ringner2008principal,greenacre2022principal,JMLR:v12:pedregosa11a}''', + 'UMAP':r'''Uniform Manifold Approximation and Projection (UMAP) \cite{ghojogh2021uniform,JMLR:v12:pedregosa11a}''', + 'NMF':r'''Non-negative Matrix Factorization (NMF) \cite{lopes2015non}'''} # List of dimensionality reduction algos + cluster_methods = {'Kmeans':r'''Kmeans \cite{chong2021k,JMLR:v12:pedregosa11a}''', + 'HDBSCAN':r'''Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN) \cite{mcinnes2017hdbscan}''', + 'AP':r'''Affinity Propagation (AP) \cite{dueck2009affinity,JMLR:v12:pedregosa11a}''', + 'KS':r'''Kennard-Stone algorithm (KS)''', + 'RDM': r'''random approach'''} # List of clustering algos selec_strategy = {'center':'PCA','random':'PCA'} - reg_algo ={"PLS":'Partial Least Squares (PLS) \cite{Wold2001,JMLR:v12:pedregosa11a}', - "LW-PLS": 'Locally Weighted-Partial Least Squares (LW-PLS) \cite{Lesnoff2020}', - "TPE-iPLS": "Tree-structured Parzen estimator-interval Partial Least Squares (TPE-iPLS)"} + reg_algo ={"PLS":r'''Partial Least Squares (PLS) \cite{Wold2001,JMLR:v12:pedregosa11a}''', + "LW-PLS": r'''Locally Weighted-Partial Least Squares (LW-PLS) \cite{Lesnoff2020}''', + "TPE-iPLS": r'''Tree-structured Parzen estimator-interval Partial Least Squares (TPE-iPLS)'''} to_report=[] j=0 @@ -176,19 +176,19 @@ def report(*args): large residual distance to the subspace, but whose projection is on the subspace; and, finally, bad leverage points, which have a large residual distance such that the projection on the subspace is away from regular observations.\par""" - latex_report += """ Results of applying this workflow are displayed in""" + latex_report += r""" Results of applying this workflow are displayed in""" if 'PCA' in to_report: - latex_report += """ (\cref{pcaplots, hotelling_and_influence, loadings}).""" + latex_report += r""" (\cref{pcaplots, hotelling_and_influence, loadings}).""" elif 'NMF' in to_report: - latex_report += """ (\cref{pcaplots, loadings}).""" + latex_report += r""" (\cref{pcaplots, loadings}).""" else: - latex_report += """ (\cref{pcaplots}).""" + latex_report += r""" (\cref{pcaplots}).""" if 'KS' in to_report or 'RDM' in to_report: - latex_report += """ Based of the features extracted using {"""+to_report[2]+ r"""}, """ + latex_report += r""" Based of the features extracted using {"""+to_report[2]+ r"""}, """ else: - latex_report += """ Based of the features extracted using {"""+to_report[2]+ r"""}, + latex_report += r""" Based of the features extracted using {"""+to_report[2]+ r"""}, {"""+to_report[3]+ r"""} revealed the existance of {"""+to_report[5] + r"""} data clusters, visualized with different colors, from which """ latex_report += r"""a subset of {"""+to_report[8]+ r"""} samples was selected""" diff --git a/src/pages/1-samples_selection.py b/src/pages/1-samples_selection.py index 710da37..56d8a0d 100644 --- a/src/pages/1-samples_selection.py +++ b/src/pages/1-samples_selection.py @@ -414,6 +414,7 @@ if not t.empty: st.write('Scores plot') tcr_plot = tcr.copy() colfilter = st.selectbox('Color by:', options= filter,format_func = lambda x: x if x else "<Select>") + p_hash(colfilter) if colfilter in cluster_methods: tcr_plot[colfilter] = labels elif not meta_data.empty and colfilter in md_df_st_.columns.tolist(): diff --git a/src/pages/3-prediction.py b/src/pages/3-prediction.py index bed4a0e..eb3cf20 100644 --- a/src/pages/3-prediction.py +++ b/src/pages/3-prediction.py @@ -158,8 +158,8 @@ try: with M4: @st.cache_data def prep_info(change): - SG = f'- Savitzky-Golay derivative parameters \:(Window_length:{prep['window_length']}; polynomial order: {prep['polyorder']}; Derivative order : {prep['deriv']})' - Norm = f'- Spectral Normalization \: {norm}' + SG = r'''- Savitzky-Golay derivative parameters \:(Window_length:{prep['window_length']}; polynomial order: {prep['polyorder']}; Derivative order : {prep['deriv']})''' + Norm = r'''- Spectral Normalization \: {norm}''' return SG, Norm SG, Norm = prep_info(change = hash_) st.info('The spectra were preprocessed using:\n'+SG+"\n"+Norm) diff --git a/src/pages/4-inputs.py b/src/pages/4-inputs.py index 472cde4..959f84d 100644 --- a/src/pages/4-inputs.py +++ b/src/pages/4-inputs.py @@ -69,30 +69,31 @@ with st.container(): } submitted = st.form_submit_button(label='Save') - if submitted: - if '' not in form_data.values(): - # Save the form data here - st.session_state['form_submitted'] = True - st.success('Form was saved successfully!', icon="✅") - # Enregistrement des données dans un fichier JSON - with open('form_data.json', 'w') as json_file: - json.dump(form_data, json_file) - - with st.container(): - if st.session_state['interface'] == 'simple': - header3, header4 = st.columns(2) - if header3.button("Samples Selection"): - st.switch_page(pages_folder / '1-samples_selection.py') - if header4.button("Model Creation"): - st.switch_page(pages_folder / '2-model_creation.py') - elif st.session_state['interface'] == 'advanced': - header3, header4, header5 = st.columns(3) - if header3.button("Samples Selection"): - st.switch_page(pages_folder / '1-samples_selection.py') - if header4.button("Model Creation"): - st.switch_page(pages_folder / '2-model_creation.py') - if header5.button("Prediction"): - st.switch_page(pages_folder / '3-prediction.py') - - else: - st.error('Error: The form was not saved, please ensure the required fields are filled!') \ No newline at end of file + if submitted: + if '' not in form_data.values(): + # Save the form data here + st.session_state['form_submitted'] = True + st.success('Form was saved successfully!', icon="✅") + # Enregistrement des données dans un fichier JSON + with open('form_data.json', 'w') as json_file: + json.dump(form_data, json_file) + + if st.session_state['interface'] == 'simple': + header3, header4 = st.columns(2) + if header3.button("Samples Selection"): + st.switch_page(pages_folder / '1-samples_selection.py') + if header4.button("Model Creation"): + st.switch_page(pages_folder / '2-model_creation.py') + elif st.session_state['interface'] == 'advanced': + header3, header4, header5 = st.columns(3) + if header3.button("Samples Selection"): + st.switch_page(pages_folder / '1-samples_selection.py') + if header4.button("Model Creation"): + st.switch_page(pages_folder / '2-model_creation.py') + if header5.button("Prediction"): + st.switch_page(pages_folder / '3-prediction.py') + + else: + st.error('Error: The form was not saved, please ensure the required fields are filled!') + + -- GitLab