You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
miner/frontend/pages/clustering_kmeans.py

27 lines
989 B

import streamlit as st
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../backend')))
from kmeans_strategy import perform_kmeans_clustering
st.header("Clustering: KMeans")
if "data" in st.session_state:
data = st.session_state.data
with st.form("kmeans_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=3)
n_init = row1[2].number_input("n_init", step=1, min_value=1)
row2 = st.columns([1, 1])
max_iter = row2[0].number_input("max_iter", step=1, min_value=1)
submitted = st.form_submit_button("Launch")
if submitted and 2 <= len(data_name) <= 3:
fig = perform_kmeans_clustering(data, data_name, n_clusters, n_init, max_iter)
st.pyplot(fig)
else:
st.error("File not loaded")