debut dbscan

clustering
Bastien OLLIER 10 months ago
parent 5bf5f507a5
commit 197939555c

@ -0,0 +1,18 @@
import streamlit as st
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
import numpy as np
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)
st.form_submit_button('launch')
else:
st.error("file not loaded")

@ -2,7 +2,7 @@ import streamlit as st
from sklearn.cluster import KMeans from sklearn.cluster import KMeans
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
st.header("Clustering") st.header("Clustering: kmeans")
if "data" in st.session_state: if "data" in st.session_state:
@ -27,8 +27,9 @@ if "data" in st.session_state:
y_kmeans = kmeans.fit_predict(x) y_kmeans = kmeans.fit_predict(x)
fig, ax = plt.subplots(figsize=(12,8)) fig, ax = plt.subplots(figsize=(12,8))
plt.scatter(x[:, 0], x[:, 1], s=100, c=kmeans.labels_, cmap='Set1') plt.scatter(x[:, 0], x[:, 1], c=y_kmeans, s=50, cmap='viridis')
plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:, 1], s=400, marker='*', color='k') centers = kmeans.cluster_centers_
plt.scatter(centers[:, 0], centers[:, 1], c='black', s=200, marker='X')
st.pyplot(fig) st.pyplot(fig)
else: else:
Loading…
Cancel
Save