From f71a2342e6ef939cd33a8e0a762c7af8f343d9aa Mon Sep 17 00:00:00 2001 From: DIANE <abderrahim.diane@cefe.cnrs.fr> Date: Thu, 11 Apr 2024 16:53:50 +0200 Subject: [PATCH] PCA color filter prediction using ipls model --- pages/1-samples_selection.py | 23 +++++++++++++++-------- pages/3-prediction.py | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pages/1-samples_selection.py b/pages/1-samples_selection.py index 63e4a43..f7ca85a 100644 --- a/pages/1-samples_selection.py +++ b/pages/1-samples_selection.py @@ -6,6 +6,8 @@ from Class_Mod.DATA_HANDLING import * ################################### Data Loading and Visualization ######################################## container1 = st.container(border=True) col2, col1 = st.columns([3, 1]) +col1.header("Data Loading", divider='blue') +col2.header("Spectral Data Visualization", divider='blue') container2 = st.container(border=True) @@ -15,8 +17,6 @@ influence, hotelling, qexp = st.columns([2, 2, 1]) with container1: - col1.header("Data Loading", divider='blue') - col2.header("Spectral Data Visualization", divider='blue') # loader for csv file containing NIRS spectra sselectx_csv = col1.file_uploader("Load NIRS Data", type=["csv","dx"], help=" :mushroom: select a csv matrix with samples as rows and lambdas as columns", key=5) if sselectx_csv is not None: @@ -59,9 +59,10 @@ with container1: data = DxRead(path = tmp_path) data_import = data.specs_df_ st.success("The data have been loaded successfully", icon="✅") + ## Visualize spectra - + with col2: fig, ax = plt.subplots(figsize = (30,7)) data_import.T.plot(legend=False, ax = ax, color = 'blue') @@ -85,11 +86,10 @@ with container1: ###################################################################################### ############################## Exploratory data analysis ############################### +plot_type=['', 'PCA','UMAP', 'NMF'] +cluster_methods = ['', 'Kmeans','UMAP', 'AP'] with container2: if sselectx_csv is not None: - plot_type=['', 'PCA','UMAP', 'NMF'] - cluster_methods = ['', 'Kmeans','UMAP', 'AP'] - with pc: type_plot = st.selectbox("Dimensionality reduction techniques: ", options=plot_type, key=37) type_cluster = st.selectbox("Clustering techniques: ", options=cluster_methods, key=38) @@ -128,8 +128,15 @@ with container2: else: - fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) - fig.update_traces(marker=dict(size=4)) + if test == '.dx': + filter = ['origin', 'date', 'time', 'spectrometer/data system'] + col = st.selectbox('filter', options= filter) + + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = data.md_df_[col]) + fig.update_traces(marker=dict(size=4)) + else: + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3 ) + fig.update_traces(marker=dict(size=4)) st.plotly_chart(fig) diff --git a/pages/3-prediction.py b/pages/3-prediction.py index e7f32f7..6fba851 100644 --- a/pages/3-prediction.py +++ b/pages/3-prediction.py @@ -42,7 +42,7 @@ if NIRS_csv: if index: idx = pd.read_csv(index, sep=';', index_col=0).iloc[:,0].to_numpy() -result = '' +#result = '' if st.button("Predict"): if s: -- GitLab