I can't label the plot, which shows the 1,2,3 attributes in the c=df["hypothyroid"] column.
I tried legend(labels=[1,2,3]) and even gca().legend(labels=1,2,3]).
print("Before PCA: ", df.shape)
seed = 7
pca = PCA(n_components=2, random_state=seed)
df_pca = pca.fit_transform(df)
pca_2 = plt.scatter(df_pca[:,0], df_pca[:,1], c=df["hypothyroid"],
cmap="autumn")
plt.title("2_components PCA")
plt.xlabel("Principal Component 1")
plt.ylabel("Pringipal Component 2")
plt.gca().legend(["0","1","2"])
plt.show()
print("After PCA: ", df_pca.shape)
I need the plot to have the legend of the 1 2 3 hypothyroid classes. Like this image shows the iris classification.