Last active
May 11, 2018 18:50
-
-
Save vihar/7918710745532891acb854876152aefa 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
# Importing Modules | |
from sklearn import datasets | |
from sklearn.cluster import KMeans | |
# Loading dataset | |
iris_df = datasets.load_iris() | |
# Declaring Model | |
model = KMeans(n_clusters=3) | |
# Fitting Model | |
model.fit(iris_df.data) | |
# Predicitng a single input | |
predicted_label = model.predict([[7.2, 3.5, 0.8, 1.6]]) | |
# Prediction on the entire data | |
all_predictions = model.predict(iris_df.data) | |
# Printing Predictions | |
print(predicted_label) | |
print(all_predictions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment