K-means
K-Means clustering is one of the popular unsupervised machine learning algorithm. In supervised learning, we provide set of features and label our model learn what should be the output when we give specific type of inputs and when we give new input it predict the output. In unsupervised learning there is no labels provided. The algorithm finds patter in the inputs and form clusters. If the clusters are far from each other and inner elements of clusters are close to each other we consider it as good cluster. K-Means clustering uses simple 4 steps to get the clusters. First we give the number of clusters (k). Then a random centroid is selected for each cluster. Then the each points is assigned to the cluster and based on distance and new clusters are formed with new centroid. This process keeps on iterating until centriods of new clusters don't change. K-mean clustering can be used in document classification, recommended system, image classification, segmentation of customers etc.
Data description
we can clearly see columns like Balance, Bonus_miles, Bonus_trans, Flight_miles_12mo and Days_since_enroll have different scale. We'll have to standardize it. It will help in reducing the traning time and get better output.Â
Lets check the inertia of cluster by plotting the elbow curve graph. Inertia is sum of distance of all point in a cluster from its centroid.


















