<jupyter_start><jupyter_text>Author - <NAME> Data Science and Business Analytics Intern GRIP - The Sparks Foundation Task-2  Prediction using Unsupervised Machine Learning<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import datasets
import seaborn as sns

iris_df = pd.read_csv(r'Iris.csv')
iris_df.info()
iris_df.describe()
sns.scatterplot(x=data["SepalLengthCm"], y=data["SepalWidthCm"], hue=data["Species"])
plt.show()
sns.scatterplot(x=data["PetalLengthCm"], y=data["PetalWidthCm"], hue=data["Species"])
plt.show()
x = iris_df.iloc[:, [0, 1, 2, 3]].values
from sklearn.cluster import KMeans<jupyter_output><empty_output><jupyter_text>Using Elbow method to calculate optimum value of k<jupyter_code>wcss=[]
for i in range(1,20):
    kmeans=KMeans(n_clusters=i,init='k-means++',max_iter=500,n_init=10,random_state=0)
    kmeans.fit(x)
    wcss.append(kmeans.inertia_)            
plt.plot(range(1,20),wcss,c='red')
plt.title('The elbow method')                                  
plt.xlabel('No of Clusters')                                   
plt.ylabel('WCSS')
plt.show()
kmeans = KMeans(n_clusters = 3, init = 'k-means++',
                max_iter = 500, n_init = 10, random_state = 0)
y_kmeans = kmeans.fit_predict(x)
plt.scatter(x[y_kmeans == 0, 0], x[y_kmeans == 0, 1],                 
            s = 100, c = 'brown', label = 'Iris-setosa')
plt.scatter(x[y_kmeans == 1, 0], x[y_kmeans == 1, 1], 
            s = 100, c = 'blue', label = 'Iris-versicolour')
plt.scatter(x[y_kmeans == 2, 0], x[y_kmeans == 2, 1],
            s = 100, c = 'green', label = 'Iris-virginica')
plt.scatter(kmeans.cluster_centers_[:,0], kmeans.cluster_centers_[:,1],      
            s = 100, c = 'red', label = 'Centroids')
plt.legend()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15448504983388706, 'fraction_numerical': 0.02768549280177187, 'mean_word_length': 3.645244215938303, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '600512', 'license': 'MIT', 'n_tokens_mistral': 756, 'n_tokens_neox': 678, 'n_words': 141, 'path': 'task2/.ipynb_checkpoints/Task2-checkpoint.ipynb', 'repo_name': 'HimanchalChandra/GRIPTasks-TSF', 'size': '1817'}