# target in cluster analisys (PCA)

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.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.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?

Iris data set comes with a label, it is a supervised learning problem. The task is to predict the species of the flowers.

Your problem need not have a label, it really depends on your task and data. If your goal is to predict the gender and you want to see if you can see a pattern in lower dimensional space, you can give it a try to treat gender as a target.

If your problem is an unsupervised one, You can also just plot out your data and see whether you see any clustering in your dataset.

Remark: You might want to be careful about the $$0$$ values, $$0$$ doesn't mean the movie is good or bad. It really means no feedback.

• Can i create a label with other element in the dataset? merged the 2 df (one with user and movie , and one with information about person) ..i tried but i m not sure that i can do – theantomc Mar 6 '19 at 12:44
• you mean if you can append two dataframe together? of course you can. But you should ask yourself, what problem are you trying to solve. Are you trying to understand if we can deduce the gender from the movies? Also, those $0$ values, you might want some preprocessing. – Siong Thye Goh Mar 6 '19 at 12:48
• because my dataset will be too sparse with all 0 values? and make more noise in the data? you mean this? – theantomc Mar 6 '19 at 13:36
• If you view $0$ as really a number, your algorithm might really view it as a very very bad movie since it is less than $1$ but that is not reflective of the truth. It is in fact a label that we do not have information at that value. – Siong Thye Goh Mar 6 '19 at 13:41
• Have any suggestion? I can use a median maybe – theantomc Mar 6 '19 at 13:59