Skip to content

66 feature visualize clusters method - #128

Open
idanmoradarthas wants to merge 3 commits into
masterfrom
66-feature-visualize_clusters-method
Open

idanmoradarthas wants to merge 3 commits into
masterfrom
66-feature-visualize_clusters-method

Conversation

@idanmoradarthas

@idanmoradarthas idanmoradarthas commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #66

Adds cluster visualization utilities to the unsupervised module so users can quickly evaluate clustering results on a 2D scatter plot (with optional centroids and dimensionality reduction).

What’s included

  • plot_clusters (matplotlib) – static 2D scatter plot of clustering results
  • plot_clusters_plotly – interactive Plotly version with hover info
  • Automatic dimensionality reduction for data with >2 features:
    • PCA (default)
    • t-SNE
    • UMAP (optional extra: pip install data-science-utils[umap])
  • Optional cluster centroid overlay
  • Support for existing axes / figures
  • Full documentation updates (README.md, docs/source/unsupervised.rst, SKILL.md, CHANGELOG.md)
  • Installation notes for the new [umap] extra
  • Comprehensive unit tests + baseline images for visual regression

Motivation (from #66)

Unsupervised models (KMeans, DBSCAN, etc.) produce cluster labels, but interpreting them usually requires boilerplate plotting code. These helpers reduce that friction and integrate visualization directly into the modeling workflow.

Example usage

from sklearn.cluster import KMeans
from ds_utils.unsupervised import plot_clusters, plot_clusters_plotly
from matplotlib import pyplot as plt

estimator = KMeans(n_clusters=8, random_state=42)
estimator.fit(X)

# Matplotlib
plot_clusters(X, estimator.labels_, estimator.cluster_centers_)
plt.show()

# Plotly (interactive)
fig = plot_clusters_plotly(X, estimator.labels_, estimator.cluster_centers_)
fig.show()

- Introduced `plot_clusters` and `plot_clusters_plotly` functions for 2D scatter plots of clustering results, with options for PCA, t-SNE, and UMAP dimensionality reduction.
- Added support for UMAP through the optional `data-science-utils[umap]` installation.
- Updated documentation in `README.md`, `CHANGELOG.md`, and `SKILL.md` to include usage examples and installation instructions for new features.
- Enhanced tests for cluster plotting functions to ensure robust validation of functionality and error handling.
…sualization features

- Removed the "Unreleased" section from CHANGELOG.md.
- Documented the addition of `plot_clusters` and `plot_clusters_plotly` functions for 2D scatter plots of clustering results.
- Included details about the optional `data-science-utils[umap]` for UMAP support in cluster visualization.
@idanmoradarthas idanmoradarthas self-assigned this Sep 25, 2026
@idanmoradarthas idanmoradarthas linked an issue Sep 25, 2026 that may be closed by this pull request
9 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: visualize_clusters Method

1 participant