You are on page 1of 1

#Store and read the data

import pandas as pd
sup_df = pd.read_csv("supplier.csv" )
sup_df

#plot the data


import numpy as np
import matplotlib.pyplot as plt
import seaborn as sn
sn.lmplot( "quality_index", "delivery_index", data=sup_df, fit_reg = False, size =
4 );
plt.title( "quality and delivery index data of supplier");

#Selecting the features


new_sup_df = sup_df[["quality_index", "delivery_index"]]
new_sup_df

#K-means Clustering
from sklearn.cluster import KMeans
clusters_new = KMeans( 2 )
clusters_new.fit( new_sup_df )
new_sup_df["clusterid"] = clusters_new.labels_
new_sup_df

#Plot the clusters


import seaborn as sn
markers = ['+','^']
sn.lmplot( "quality_index", "delivery_index",data=new_sup_df,hue = "clusterid",
fit_reg=False,markers = markers, size = 4 );

You might also like