
Co-authored-by: bastien ollier <bastien.ollier@etu.uca.fr> Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/miner/pulls/13 Reviewed-by: Hugo PRADIER <hugo.pradier2@etu.uca.fr> 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>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import streamlit as st
|
|
import matplotlib.pyplot as plt
|
|
from clusters import DBSCAN_cluster
|
|
|
|
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=3)
|
|
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 and len(data_name) <=3:
|
|
x = data[data_name].to_numpy()
|
|
|
|
dbscan = DBSCAN_cluster(eps,min_samples,x)
|
|
y_dbscan = dbscan.run()
|
|
st.table(dbscan.get_stats())
|
|
|
|
fig = plt.figure()
|
|
if len(data_name) == 2:
|
|
ax = fig.add_subplot(projection='rectilinear')
|
|
plt.scatter(x[:, 0], x[:, 1], c=y_dbscan, s=50, cmap="viridis")
|
|
else:
|
|
ax = fig.add_subplot(projection='3d')
|
|
ax.scatter(x[:, 0], x[:, 1],x[:, 2], c=y_dbscan, s=50, cmap="viridis")
|
|
st.pyplot(fig)
|
|
else:
|
|
st.error("file not loaded") |