July 2018
Beginner to intermediate
146 pages
3h 39m
English
The k-means algorithm, although very powerful, is not ideal for every use case.
To illustrate, let's construct a plot with two half moons. Like the preceding blobs, scikit-learn gives us a convenient function to plot half-moon clusters:
#Import the half moon function from scikit-learnfrom sklearn.datasets import make_moons#Get access to points using the make_moons functionX_m, y_m = make_moons(200, noise=.05, random_state=0)#Plot the two half moon clustersplt.scatter(X_m[:, 0], X_m[:, 1], s=50)

Will the k-means algorithm be able to figure out the two half moons correctly? Let's find out:
#Initialize K-Means Object ...
Read now
Unlock full access