beter clusters and qol
This commit is contained in:
@@ -7,7 +7,8 @@ import numpy as np
|
||||
from config import (
|
||||
APP_TITLE, APP_ICON, APP_LAYOUT, METHOD_EXPLANATIONS,
|
||||
CLUSTERING_METHODS_REQUIRING_N_CLUSTERS, COMPUTATIONALLY_INTENSIVE_METHODS,
|
||||
LARGE_DATASET_WARNING_THRESHOLD, MAX_DISPLAYED_AUTHORS
|
||||
LARGE_DATASET_WARNING_THRESHOLD, MAX_DISPLAYED_AUTHORS,
|
||||
DEFAULT_DIMENSION_REDUCTION_METHOD, DEFAULT_CLUSTERING_METHOD
|
||||
)
|
||||
|
||||
|
||||
@@ -38,17 +39,23 @@ def create_method_controls():
|
||||
)
|
||||
|
||||
# Dimension reduction method
|
||||
method_options = ["PCA", "t-SNE", "UMAP", "Spectral Embedding", "Force-Directed"]
|
||||
default_index = method_options.index(DEFAULT_DIMENSION_REDUCTION_METHOD) if DEFAULT_DIMENSION_REDUCTION_METHOD in method_options else 0
|
||||
method = st.sidebar.selectbox(
|
||||
"Dimension Reduction Method",
|
||||
["PCA", "t-SNE", "UMAP", "Spectral Embedding", "Force-Directed"],
|
||||
method_options,
|
||||
index=default_index,
|
||||
help="PCA is fastest, UMAP balances speed and quality, t-SNE and Spectral are slower but may reveal better structures. Force-Directed creates natural spacing."
|
||||
)
|
||||
|
||||
# Clustering method
|
||||
clustering_options = ["None", "HDBSCAN", "Spectral Clustering", "Gaussian Mixture",
|
||||
"Agglomerative (Ward)", "Agglomerative (Complete)", "OPTICS"]
|
||||
clustering_default_index = clustering_options.index(DEFAULT_CLUSTERING_METHOD) if DEFAULT_CLUSTERING_METHOD in clustering_options else 0
|
||||
clustering_method = st.sidebar.selectbox(
|
||||
"Clustering Method",
|
||||
["None", "HDBSCAN", "Spectral Clustering", "Gaussian Mixture",
|
||||
"Agglomerative (Ward)", "Agglomerative (Complete)", "OPTICS"],
|
||||
clustering_options,
|
||||
index=clustering_default_index,
|
||||
help="Apply clustering to identify groups. HDBSCAN and OPTICS can find variable density clusters."
|
||||
)
|
||||
|
||||
@@ -57,9 +64,25 @@ def create_method_controls():
|
||||
|
||||
def create_clustering_controls(clustering_method):
|
||||
"""Create controls for clustering parameters"""
|
||||
n_clusters = 5
|
||||
# Always show the clusters slider, but indicate when it's used
|
||||
if clustering_method in CLUSTERING_METHODS_REQUIRING_N_CLUSTERS:
|
||||
n_clusters = st.sidebar.slider("Number of Clusters", 2, 15, 5)
|
||||
help_text = "Number of clusters to create. This setting affects the clustering algorithm."
|
||||
disabled = False
|
||||
elif clustering_method == "None":
|
||||
help_text = "Clustering is disabled. This setting has no effect."
|
||||
disabled = True
|
||||
else:
|
||||
help_text = f"{clustering_method} automatically determines the number of clusters. This setting has no effect."
|
||||
disabled = True
|
||||
|
||||
n_clusters = st.sidebar.slider(
|
||||
"Number of Clusters",
|
||||
min_value=2,
|
||||
max_value=20,
|
||||
value=5,
|
||||
disabled=disabled,
|
||||
help=help_text
|
||||
)
|
||||
|
||||
return n_clusters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user