<jupyter_start><jupyter_text>Prediction using Unsupervised ML It is based on iris dataset,In this section use clustering using kmeans from sklearn library after that I visualize the data, using scatter ploting.<jupyter_code># import libraries
import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
from matplotlib import pyplot
import seaborn
data  = pd.read_csv('Iris.csv')
data
# remove unnecessary columns
data = data.iloc[:,1:]
data.info()
data
x = data.iloc[:,:-1].values
x[:,0]
y = data.iloc[:,-1].values
y
# convert string to int mean machine-readable form.
from sklearn.preprocessing import LabelEncoder
y_labal = LabelEncoder()
y = y_labal.fit_transform(y)
y<jupyter_output><empty_output><jupyter_text>Elbow Method<jupyter_code>#  Elbow method to find suitable k for clustering.
sum_squer_error = []
for i in range(1,11):
    km = KMeans(n_clusters=i)
    km.fit(x)
    sum_squer_error.append(km.inertia_)
pyplot.xlabel('K')
pyplot.ylabel('ssc')
pyplot.plot(range(1,11),sum_squer_error)
pyplot.title('Elbow Method')
pyplot.grid(True)
#  from elbow method K= 3.
kmeans = KMeans(n_clusters=3)
kmeans.fit(x)
y_means = kmeans.predict(x)
y_means
pd.DataFrame({'precdiction':y_means,'actual':y})<jupyter_output><empty_output><jupyter_text>Visualization of Iris dataset with 3 clusters Using the elbow method we found that there is 3 optimum cluster for this  iris dataset<jupyter_code>pyplot.scatter(x[:,0],x[:,2],c = y_means)
pyplot.xlabel('SepalLength(cm)')
pyplot.ylabel('PetalLength(cm)')
pyplot.title('SepalLength v/s PetalLenfth')
pyplot.scatter(data['Species'],data['SepalWidthCm'])<jupyter_output><empty_output><jupyter_text>To better understanding we use seaborn library .<jupyter_code>import seaborn
seaborn.swarmplot(x = 'Species',y= 'SepalWidthCm',data=data)
seaborn.swarmplot(x = 'Species',y= 'PetalLengthCm',data=data)<jupyter_output>/home/nachiket/.local/lib/python3.6/site-packages/seaborn/categorical.py:1296: UserWarning: 14.0% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)