Skip to content

Sync practical-k-means with the updated tutorial - #949

Merged
realpython-bot merged 1 commit into
masterfrom
maintenance/k-means-clustering-python-20261123
Nov 23, 2026
Merged

realpython-bot merged 1 commit into
masterfrom
maintenance/k-means-clustering-python-20261123

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Maintenance sync of practical-k-means/ with the update of K-Means Clustering in Python: A Practical Guide.

What changed and why

  • practical-k-means-syntethic.ipynb: silhouette_score() now returns a Python float, so .round(2) raised AttributeError. The cell now uses round(..., 2), matching the updated article.
  • practical-k-means-cancer-gene-expression.ipynb: sns.scatterplot() no longer accepts positional x/y data, so the cell now passes x= and y= keywords.
  • requirements.txt: every line pinned with == to the versions the article's dependencies field now carries (scikit-learn 1.9.1, kneed 0.9.0, matplotlib 3.11.2, numpy 2.5.5, pandas 3.1.1, seaborn 0.13.2), plus jupyter 1.1.1.
  • README.md: conda commands match the article's pinned conda-forge install, and the jupyter notebook commands now name the notebooks' actual filenames.

Stored notebook outputs are left as they were to keep the diff reviewable.

Links

Verification

  • Fresh Python 3.15.2 venv with pip install -r requirements.txt, then both notebooks executed end to end with MPLBACKEND=Agg jupyter nbconvert --execute (including the TCGA dataset download): no errors, no stderr output.
  • uvx ruff@0.14.1 format --check practical-k-means and uvx ruff@0.14.1 check practical-k-means both pass.

🤖 Generated with Claude Code

…ing in Python: A Practical Guide

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@realpython-bot
realpython-bot merged commit 909cbc5 into master Nov 23, 2026
1 check passed
@realpython-bot
realpython-bot deleted the maintenance/k-means-clustering-python-20261123 branch November 23, 2026 07:01
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.

1 participant