# How can I plot data after cluster it into two cluster?

I have some unlabeled data with 15 attributes and 30161 instances. I took 70% data for clustering and cluster those data into 2 cluster. I also added one column after clustering named 'cluster' and the column '<=50k' was label column. Now I need to plot those data except label column, How can I plot it ? Here's the sample of my code and data.

Data

cols_x=train.columns[0:14] cols_y = train.columns[14] X = train[cols_x] y = train[cols_y]

from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30,random_state=10)

kmeans = KMeans(n_clusters=2) train["cluster"] = kmeans.fit_predict(train[X_train.columns[0:14]]) train.head(10)

• What exactly you want to plot, it depends on that also.. – Aditya Feb 28 '18 at 14:09
• As I clustered those data into 2 cluster. So, I need to visualized those 2 clustered data with amount that how many data exist in cluster 1 and cluster 2. – IS2057 Mar 1 '18 at 6:36
• You can do that using countplot on the target variable? – Aditya Mar 1 '18 at 6:38

• Though I am new learner in python and clustering but I didn't just copy and pasting code from internet. And here ID is not larger than 200000, may be your mentioned column is fnlwgt and this data was for adults data, which I didn't mentioned it here. I think I have clear idea about what I need to do but I faced problem about plotting. – IS2057 Jan 29 '18 at 15:36
• The column labeled 77516 determines your result. All other columns do not matter, except maybe 2174 when it isn't 0. Sorry, but it clearly looks as if you have not understood what function you optimize. – Has QUIT--Anony-Mousse Jan 29 '18 at 15:43