10 Commits

Author SHA1 Message Date
bastien ollier
34f70b4d79 delete np 2024-06-19 09:34:52 +02:00
bastien ollier
64cf65a417 max nb cluster to nb line 2024-06-19 09:28:25 +02:00
bastien ollier
d4e33e7367 dbscan 2024-06-19 09:20:59 +02:00
bastien ollier
72dcc8ff1c add dbscan 2024-06-19 09:17:12 +02:00
bastien ollier
9fc6d7d2d1 add dbscan 2024-06-19 09:16:10 +02:00
bastien ollier
197939555c debut dbscan 2024-06-19 08:45:34 +02:00
bastien ollier
5bf5f507a5 end clustering 2024-06-07 11:56:38 +02:00
bastien ollier
4ae8512dcb add form 2024-06-07 11:29:18 +02:00
Bastien OLLIER
ba1aef5727 Add navigation (#2)
Co-authored-by: bastien ollier <bastien.ollier@etu.uca.fr>
Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr>
Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/miner/pulls/2
Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr>
Co-authored-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr>
Co-committed-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr>
2024-06-07 10:25:37 +02:00
Bastien OLLIER
440265faaa Merge pull request 'Ajout de la partie visualisation' (#1) from visualisation into main
Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/miner/pulls/1
2024-06-05 09:33:06 +02:00
5 changed files with 142 additions and 64 deletions

47
frontend/exploration.py Normal file
View File

@@ -0,0 +1,47 @@
import pandas as pd
import streamlit as st
st.set_page_config(
page_title="Project Miner",
layout="wide"
)
st.title("Home")
### Exploration
uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"])
if uploaded_file is not None:
st.session_state.data = pd.read_csv(uploaded_file)
st.success("File loaded successfully!")
if "data" in st.session_state:
data = st.session_state.data
st.write(data.head(10))
st.write(data.tail(10))
st.header("Data Preview")
st.subheader("First 5 Rows")
st.write(data.head())
st.subheader("Last 5 Rows")
st.write(data.tail())
st.header("Data Summary")
st.subheader("Basic Information")
col1, col2 = st.columns(2)
col1.metric("Number of Rows", data.shape[0])
col2.metric("Number of Columns", data.shape[1])
st.write(f"Column Names: {list(data.columns)}")
st.subheader("Missing Values by Column")
missing_values = data.isnull().sum()
st.write(missing_values)
st.subheader("Statistical Summary")
st.write(data.describe())

View File

@@ -1,64 +0,0 @@
import pandas as pd
import streamlit as st
import matplotlib.pyplot as plt
import seaborn as sns
from pandas.api.types import is_numeric_dtype
st.set_page_config(
page_title="Project Miner",
layout="wide"
)
### Exploration
uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"])
if uploaded_file:
data = pd.read_csv(uploaded_file)
st.success("File loaded successfully!")
st.header("Data Preview")
st.subheader("First 5 Rows")
st.write(data.head())
st.subheader("Last 5 Rows")
st.write(data.tail())
st.header("Data Summary")
st.subheader("Basic Information")
col1, col2 = st.columns(2)
col1.metric("Number of Rows", data.shape[0])
col2.metric("Number of Columns", data.shape[1])
st.write(f"Column Names: {list(data.columns)}")
st.subheader("Missing Values by Column")
missing_values = data.isnull().sum()
st.write(missing_values)
st.subheader("Statistical Summary")
st.write(data.describe())
### Visualization
st.header("Data Visualization")
st.subheader("Histogram")
column_to_plot = st.selectbox("Select Column for Histogram", data.columns)
if column_to_plot:
fig, ax = plt.subplots()
ax.hist(data[column_to_plot].dropna(), bins=20, edgecolor='k')
ax.set_title(f'Histogram of {column_to_plot}')
ax.set_xlabel(column_to_plot)
ax.set_ylabel('Frequency')
st.pyplot(fig)
st.subheader("Boxplot")
dataNumeric = data.select_dtypes(include='number')
column_to_plot = st.selectbox("Select Column for Boxplot", dataNumeric.columns)
if column_to_plot:
fig, ax = plt.subplots()
sns.boxplot(data=data, x=column_to_plot, ax=ax)
ax.set_title(f'Boxplot of {column_to_plot}')
st.pyplot(fig)

View File

@@ -0,0 +1,29 @@
import streamlit as st
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
st.header("Clustering: dbscan")
if "data" in st.session_state:
data = st.session_state.data
with st.form("my_form"):
data_name = st.multiselect("Data Name", data.select_dtypes(include="number").columns, max_selections=2)
eps = st.slider("eps", min_value=0.0, max_value=1.0, value=0.5, step=0.01)
min_samples = st.number_input("min_samples", step=1, min_value=1, value=5)
st.form_submit_button("launch")
if len(data_name) == 2:
x = data[data_name].to_numpy()
dbscan = DBSCAN(eps=eps, min_samples=min_samples)
y_dbscan = dbscan.fit_predict(x)
fig, ax = plt.subplots(figsize=(12,8))
plt.scatter(x[:, 0], x[:, 1], c=y_dbscan, s=50, cmap="viridis")
st.pyplot(fig)
else:
st.error("file not loaded")

View File

@@ -0,0 +1,36 @@
import streamlit as st
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
st.header("Clustering: kmeans")
if "data" in st.session_state:
data = st.session_state.data
with st.form("my_form"):
row1 = st.columns([1,1,1])
n_clusters = row1[0].selectbox("Number of clusters", range(1,data.shape[0]))
data_name = row1[1].multiselect("Data Name",data.select_dtypes(include="number").columns, max_selections=2)
n_init = row1[2].number_input("n_init",step=1,min_value=1)
row2 = st.columns([1,1])
max_iter = row1[0].number_input("max_iter",step=1,min_value=1)
st.form_submit_button("launch")
if len(data_name) == 2:
x = data[data_name].to_numpy()
kmeans = KMeans(n_clusters=n_clusters, init="random", n_init=n_init, max_iter=max_iter, random_state=111)
y_kmeans = kmeans.fit_predict(x)
fig, ax = plt.subplots(figsize=(12,8))
plt.scatter(x[:, 0], x[:, 1], c=y_kmeans, s=50, cmap="viridis")
centers = kmeans.cluster_centers_
plt.scatter(centers[:, 0], centers[:, 1], c="black", s=200, marker="X")
st.pyplot(fig)
else:
st.error("file not loaded")

View File

@@ -0,0 +1,30 @@
import streamlit as st
import matplotlib.pyplot as plt
import seaborn as sns
st.header("Data Visualization")
if "data" in st.session_state:
data = st.session_state.data
st.subheader("Histogram")
column_to_plot = st.selectbox("Select Column for Histogram", data.columns)
if column_to_plot:
fig, ax = plt.subplots()
ax.hist(data[column_to_plot].dropna(), bins=20, edgecolor='k')
ax.set_title(f"Histogram of {column_to_plot}")
ax.set_xlabel(column_to_plot)
ax.set_ylabel("Frequency")
st.pyplot(fig)
st.subheader("Boxplot")
dataNumeric = data.select_dtypes(include="number")
column_to_plot = st.selectbox("Select Column for Boxplot", dataNumeric.columns)
if column_to_plot:
fig, ax = plt.subplots()
sns.boxplot(data=data, x=column_to_plot, ax=ax)
ax.set_title(f"Boxplot of {column_to_plot}")
st.pyplot(fig)
else:
st.error("file not loaded")