Created
May 31, 2019 12:30
-
-
Save spikar/8da8cf7ab42de8d4fe460c6ecbe1ab52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.cluster import KMeans | |
# Number of clusters | |
kmeans = KMeans(n_clusters=k) | |
# Fitting the input data | |
kmeans = kmeans.fit(X) | |
# Getting the cluster labels | |
labels = kmeans.predict(X) | |
# Centroid values | |
centroids = kmeans.cluster_centers_ | |
# Comparing with scikit-learn centroids | |
print(C) # From Scratch | |
print(centroids) # From sci-kit learn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment