import matplotlib.pyplot as plt from sklearn.cluster import KMeans %matplotlib inline kmean_model = KMeans(init='k-means++') kmean_model.fit(df) predict = kmean_model.predict(df) plt.scatter(df.iloc[:,2],df.iloc[:,3],c = predict,cmap = 'viridis')