Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created May 5, 2021
Embed
What would you like to do?
colors = {0:"red", 1:"yellow", 2:"blue", 3:"green", 4:"pink"}
pca = PCA()
principal_components = pca.fit_transform(x)
x, y = principal_components[:,0], principal_components[:,1]
df = pd.DataFrame({"X": x, "Y": y, "Labels": labels})
groups = df.groupby(labels)
fig, ax = plt.subplots(figsize=(15, 10))
for i, j in groups:
ax.plot(j.X, j.Y, marker='o', linestyle='', ms=5, color=colors[i], mec='none')
ax.set_aspect('auto')
ax.tick_params(axis='x',which='both',bottom='off',top='off',labelbottom='off')
ax.tick_params(axis= 'y',which='both',left='off',top='off',labelleft='off')
ax.set_title("Credit Card Customer Segmentation")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment