9 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
2 changed files with 65 additions and 0 deletions

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")