Hey Marco! If you check out the link to the code I provided to someone else who asked for it, the sklearn library uses PCA to transform your data into a new set of data with reduced features. As for choosing the number of dimensions, if I want to visualize it, I had to choose between 3 or 2. Of course, because we see the visualizations on a 2-d surface, a 3-d plot is usually ineffective, and if you check the explained variance ratio sum for three vs. two dimensions, having three dimensions does not add a lot of explained variance. Usually for PCA visualization, we choose two dimensions, unless adding the third dimension adds a lot of explained variance. Cheers!

ML & CS enthusiast. Let’s connect: https://www.linkedin.com/in/andre-ye.

ML & CS enthusiast. Let’s connect: https://www.linkedin.com/in/andre-ye.