i m doing dimensionaly reduction using PCA. I don't understand why some dataset already had a target ad example in Iris database or other like this (https://scikit-learn.org/stable/datasets/index.html) had a target_names useful when plot data.
Ad example in iris database choose like color= target_names to do this
i found this code online in example.
fig = plt.figure(figsize = (8,8)) ax = fig.add_subplot(1,1,1) ax.set_xlabel('Principal Component 1', fontsize = 15) ax.set_ylabel('Principal Component 2', fontsize = 15) ax.set_title('2 component PCA', fontsize = 20) targets = ['Iris-setosa', 'Iris-versicolor', 'Iris-virginica'] colors = ['r', 'g', 'b'] for target, color in zip(targets,colors): indicesToKeep = finalDf['target'] == target ax.scatter(finalDf.loc[indicesToKeep, 'principal component 1'] , finalDf.loc[indicesToKeep, 'principal component 2'] , c = color , s = 50) ax.legend(targets) ax.grid()
I m trying to do the same with my dataset, where i dont have a target
i have a table in this way
User Movie 0 1 2 3 4 0 2 0 5 0 0 1 0 1 1 0 0 2 0 5 5 5 0
for each user i have all film and him review (0 if don't review)
When plot my graph i tried to do this
fig = plt.figure(figsize = (16,12)) ax = fig.add_subplot(111) ax.scatter(a,b, alpha = 1) plt.title('Method: PCA') #plt.savefig('PCA.png', dpi = 300) plt.show()
but i really don't know where is my target. I try to add another column to my dataset with gender for user for cluster user for gender but give an error of the shape because i just have a 2 gender but 6000 user.
I really don't know to apply a target in this way, Same suggestion?