k-Means i wybór k
Metody łokcia i sylwetki
k-Means i wybór k to bezpłatna lekcja Data Science Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Data Science Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Data Science Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
The Go-To Clusterer
k-Means is the most popular clustering algorithm: it splits your data into k groups by grouping points around central anchors. 🎯
Centroids Are Anchors
Each cluster has a centroid, the mean position of its members. Points join the cluster whose centroid sits closest to them.
The Repeating Dance
k-Means alternates two steps: assign every point to its nearest centroid, then recompute each centroid from its new members.
It Settles Down
Those steps repeat until assignments stop changing. The algorithm has converged, and the clusters are final.
You Choose k First
k-Means cannot invent the number of groups. You must pick k up front, and the right value is rarely obvious.
Run It in One Line
scikit-learn makes fitting easy. Set n_clusters to your chosen k and call fit on your scaled data.
from sklearn.cluster import KMeans
model = KMeans(n_clusters=3).fit(X)Inertia Measures Tightness
After fitting, inertia reports the total squared distance from points to their centroids. Lower means tighter clusters.
model.inertia_The Elbow Method
Plot inertia for many k values. Where the curve bends sharply, the elbow, often marks a good number of clusters.
Diminishing Returns
Past the elbow, adding clusters barely lowers inertia. That flattening signals you are just splitting groups that already fit well.
The Silhouette Score
A second guide is the silhouette score: it rewards points that sit close to their own cluster and far from others.
from sklearn.metrics import silhouette_scoreStart Smarter
Random starts can land badly, so scikit-learn defaults to k-means++, which spreads initial centroids out for steadier results.
Quick Check
Let us check how you would pick a sensible k.
Recap
k-Means groups points around centroids for a chosen k; the elbow and silhouette help you pick that k well. 🎯
Często zadawane pytania
Czy lekcja „k-Means i wybór k” jest bezpłatna?
Tak — pełny tekst „k-Means i wybór k” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Data Science Academy, przejdź na CoddyKit PRO. Kurs Data Science Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „k-Means i wybór k”?
Metody łokcia i sylwetki Ćwiczysz Data Science Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Data Science Academy?
Nie wymagamy żadnego doświadczenia. Data Science Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.
Ile czasu zajmuje lekcja „k-Means i wybór k”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Data Science Academy?
Tak. Każda lekcja Data Science Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Uczenie nadzorowane a nienadzorowane
- k-Means i wybór k
- Metody hierarchiczne i DBSCAN
- Profilowanie i nazywanie klastrów