Dimension

Analyse en composantes principales

Steven Golovkine

26 sept. 2025

logo

Pourquoi réduire la dimension ?


Travailler avec un grand nombre de variables pose plusieurs défis :

  • Visualisation compliquée : impossible de représenter au-delà de 3 dimensions.

  • Séparation des classes difficile : structure cachée dans des combinaisons.

  • Coût computationnel élevé : modèles complexes difficiles à ajuster.

  • Corrélations fortes : variables redondantes, modèles instables.

→ Peut-on réduire la dimension sans perdre trop d’information ?

Plan


  1. La théorie de l’analyse en composantes principales

  2. L’ACP en pratique

  3. Exemple : Le top 10 des artistes Spotify

L’approche PCA


Principe → Ne pas simplement supprimer des variables, mais construire de nouvelles variables.


Méthode → Créer des combinaisons linéaires des variables initiales qui résument l’information essentielle.

L’approche PCA


Analyse en Composantes Principales (ACP) → Méthode non-supervisée pour réduire la dimension tout en conservant le maximum d’information.


→ Introduite par Hotelling (1933).

Applications courantes


  • Visualisation : Représenter des données multidimensionnelles.

  • Réduction dimensionnelle : Passer de \(p\) à \(k \ll p\) variables.

  • Compression : Images ou signaux.

  • Exploration : Données biologiques, textuelles, environnementales, …

Exemples concrets


  • Sport : Comparer des équipes de hockey sur 6 statistiques.

  • Criminologie : Résumer la criminalité entre provinces sur 7 types de crimes.

  • Imagerie : Compresser des images de \(1084 \times 1084\) pixels.

  • Biologie : Identifier des variants de tumeurs à partir de millions de gènes.

Formulation mathématique


Soit \(X = (X_1, \ldots, X_p)^{\top}\) un vecteur aléatoire centré avec matrice de covariance \(\Sigma\).

On cherche une combinaison linéaire des variables \(X_k\) : \[Y_1 = \alpha_1^{\top} X = \sum_{k=1}^p \alpha_{1k} X_k.\]

Objectif → Maximiser \(\text{Var}(Y_1)\) sous contrainte \(\|\alpha_1\| = 1\).

Problème d’optimisation


Le problème d’optimisation s’écrit : \[\max_{\alpha_1^{\top} \alpha_1 = 1} \text{Var}(Y_1) = \max_{\alpha_1^{\top} \alpha_1 = 1} \alpha_1^{\top} \Sigma \alpha_1.\]

Problème d’optimisation

Problème d’optimisation


Solution (multiplicateurs de Lagrange) : \[\Sigma \alpha_1 = \lambda_1 \alpha_1\]

\(\lambda_1\) est la plus grande valeur propre de \(\Sigma\) et \(\alpha_1\) le vecteur propre associé.

Construction des composantes


Les composantes suivantes sont construites par orthogonalité :

\[\Sigma \alpha_k = \lambda_k \alpha_k, \quad \lambda_1 \geq \lambda_2 \geq \ldots \geq \lambda_p\]

Composantes principales : \[Y_k = \alpha_k^{\top} X\]

\(\alpha_k\) est le vecteur propre associé à \(\lambda_k\).

Représentation matricielle


Soit \(A = (\alpha_1, \ldots, \alpha_p) \in \mathbb{R}^{p \times p}\) la matrice des vecteurs propres.

\[Y = A^{\top} X\]

Propriétés de \(A\) :

  • \(A^{\top} A = AA^{\top} = I_p\) (orthogonale)

  • \(A^{\top} = A^{-1}\)

  • \(\Sigma A = A \Lambda\)\(\Lambda = \text{diag}(\lambda_1, \ldots, \lambda_p)\)

Variance des composantes


\[\text{Var}(Y) = A^{\top} \Sigma A = \Lambda\]

Conséquences :

  • \(\text{Cov}(Y_k, Y_l) = 0\) si \(k \neq l\) (orthogonalité)

  • \(\text{Var}(Y_k) = \lambda_k\) (variance décroissante)

  • \(\text{Var}(Y_1) \geq \text{Var}(Y_2) \geq \ldots \geq \text{Var}(Y_p)\)

Variation totale


La trace de Pillai est une mesure globale de la variation présente dans les données :

\[\text{tr}(\Sigma) = \sum_{i=1}^p \lambda_i = \sum_{k=1}^p \text{Var}(Y_k).\]

Proportion expliquée par \(Y_k\)


La proportion de variance expliquée par la composante principale \(Y_k\) est

\[\frac{\lambda_k}{\lambda_1 + \cdots + \lambda_p} = \frac{\text{Var}(Y_k)}{\text{tr}(\Sigma)}.\]

Proportion expliquée par les \(m\) premières


La variabilité des données expliquée par les \(m\) premières composantes est :

\[100\% \times \frac{\sum_{k=1}^m \lambda_k}{\sum_{k=1}^p \lambda_k}.\]

Estimation pratique


  1. En pratique, \(\Sigma\) est inconnue. On l’estime par : \[\hat{\Sigma} = \frac{1}{n-1} \sum_{i=1}^n (X_i - \overline{X})(X_i - \overline{X})^{\top}.\]

  2. Décomposition spectrale : \(\hat{\Sigma} = \hat{A} \hat{\Lambda} \hat{A}^{\top}.\)

  3. Composantes estimées : \(Y_i = \hat{A}^{\top} X_i.\)

Sensibilité à l’échelle


Problème → Variables avec grandes variances dominent l’ACP.

Exemple → Distance en m vs km multiplie la variance par \(10^6\).

Solution → Standardiser les variables si elles ont des unités différentes.

Équivalence → ACP sur matrice de corrélations au lieu de covariances.

Interprétation géométrique


  • Rotation des axes → \(Y = A^{\top}X\) représente une rotation orthogonale.

  • Nouveaux axes → Directions de variation maximale successive.

  • Scores → \(Y_{ik} = \alpha_k^{\top} X_i\) (coordonnées dans le nouveau système).

  • Qualité de représentation \[Q_{ik} = \frac{Y_{ik}^2}{\sum_{j=1}^p Y_{ij}^2}\]

Choix du nombre de composantes


  1. Règle des 80% : Retenir assez de composantes pour expliquer 80% de la variance.

  2. Règle de Kaiser : Conserver les composantes avec \(\lambda_k > 1\) (si matrice de corrélations).

  3. Règle de Joliffe : Variante plus stricte, \(\lambda_k > 0.7\).

  4. Règle de Cattell (coude) : Chercher un point de rupture dans le graphique des valeurs propres.

Considérations pratiques


Usage dans les modèles : Utiliser les \(k\) premières composantes comme prédicteurs.

Avantages :

  • Élimine la multicolinéarité

  • Conserve l’information essentielle

Compromis :

  • Trop de composantes : pas de simplification

  • Trop peu : perte d’information pertinente

Exemple : le top 10 Spotify

On considère le jeu de données suivant :

track_name track_artist track_popularity danceability energy loudness speechiness acousticness liveness valence tempo
I Don’t Care (with Justin Bieber) - Loud Luxury Remix Ed Sheeran 66 0.748 0.9160 -2.634 0.0583 0.102000 0.0653 0.5180 122.036
Beautiful People (feat. Khalid) - Jack Wins Remix Ed Sheeran 67 0.675 0.9190 -5.385 0.1270 0.079900 0.1430 0.5850 124.982
Cross Me (feat. Chance the Rapper & PnB Rock) - M-22 Remix Ed Sheeran 58 0.679 0.9230 -6.500 0.1810 0.146000 0.1240 0.7520 121.984
South of the Border (feat. Camila Cabello & Cardi B) - Andy Jarvis Remix Ed Sheeran 66 0.805 0.8350 -4.603 0.0896 0.130000 0.3650 0.7220 125.028
bad guy (with Justin Bieber) Billie Eilish 83 0.670 0.4530 -11.265 0.2950 0.252000 0.1170 0.6800 135.055
South of the Border (feat. Camila Cabello & Cardi B) - Sam Feldt Remix Ed Sheeran 65 0.789 0.8580 -4.388 0.0404 0.220000 0.3350 0.4910 110.012
Friends (with BloodPop®) Justin Bieber 76 0.743 0.7330 -5.337 0.0375 0.004020 0.3040 0.6220 104.977
Sorry Justin Bieber 81 0.654 0.7600 -3.669 0.0450 0.079700 0.2990 0.4100 99.945
Poker Face Lady Gaga 69 0.851 0.8060 -4.618 0.0786 0.120000 0.1210 0.7760 119.001
South of the Border (feat. Camila Cabello & Cardi B) - Cheat Codes Remix Ed Sheeran 69 0.845 0.7660 -5.727 0.0658 0.212000 0.1110 0.7820 114.054
Happier - Tiësto’s AFTR:HRS Remix Ed Sheeran 53 0.684 0.8230 -4.881 0.0296 0.005760 0.2010 0.3840 117.993
bad guy Billie Eilish 95 0.701 0.4250 -10.965 0.3750 0.328000 0.1000 0.5620 135.128
A Sky Full of Stars Coldplay 78 0.551 0.6360 -7.125 0.0281 0.007130 0.2170 0.1530 124.996
everything i wanted Billie Eilish 97 0.704 0.2250 -14.454 0.0994 0.902000 0.1060 0.2430 120.006
Yummy Justin Bieber 95 0.662 0.5190 -6.554 0.1060 0.404000 0.1210 0.4950 145.841
Blinding Lights The Weeknd 98 0.513 0.7960 -4.075 0.0629 0.001470 0.0938 0.3450 171.017
Heartless The Weeknd 93 0.531 0.7500 -5.831 0.1110 0.006320 0.1170 0.1980 169.954
Lover (Remix) [feat. Shawn Mendes] Taylor Swift 85 0.448 0.6030 -7.176 0.0640 0.433000 0.0862 0.4220 205.272
The Morning The Weeknd 70 0.652 0.5490 -7.555 0.0390 0.317000 0.1040 0.1860 120.073
Shape of You Ed Sheeran 86 0.825 0.6520 -3.183 0.0802 0.581000 0.0931 0.9310 95.977
Beautiful People (feat. Khalid) Ed Sheeran 85 0.640 0.6480 -8.113 0.1870 0.124000 0.0802 0.5480 92.977
South of the Border (feat. Camila Cabello & Cardi B) Ed Sheeran 91 0.857 0.6210 -6.376 0.0824 0.148000 0.0865 0.6680 97.986
I Don’t Care (with Justin Bieber) Ed Sheeran 84 0.798 0.6750 -5.041 0.0442 0.091200 0.0894 0.8420 101.956
Orphans Coldplay 78 0.503 0.8080 -5.051 0.0450 0.025400 0.5570 0.2830 107.975
Applause Lady Gaga 70 0.669 0.7800 -4.287 0.0530 0.026500 0.1430 0.7380 139.945
Judas Lady Gaga 56 0.661 0.9370 -3.830 0.0744 0.000967 0.3550 0.5350 131.001
Blank Space Taylor Swift 78 0.760 0.7030 -5.412 0.0540 0.103000 0.0913 0.5700 95.997
The Cure Lady Gaga 70 0.697 0.5060 -4.863 0.0325 0.079200 0.0893 0.5160 100.002
Umbrella Rihanna 80 0.583 0.8290 -4.603 0.1340 0.008640 0.0426 0.5750 174.028
Just The Way You Are Bruno Mars 20 0.637 0.8430 -5.413 0.0432 0.015100 0.0876 0.4340 109.012
Don’t Stop The Music Rihanna 17 0.835 0.6690 -5.582 0.0643 0.033600 0.0535 0.5420 122.668
Photograph Ed Sheeran 84 0.614 0.3790 -10.480 0.0476 0.607000 0.0986 0.2010 107.989
You Need To Calm Down Taylor Swift 86 0.771 0.6710 -5.617 0.0553 0.009290 0.0637 0.7140 85.026
22 Taylor Swift 0 0.661 0.7240 -6.548 0.0373 0.002880 0.0631 0.6760 104.011
Baby Justin Bieber 76 0.728 0.8600 -5.237 0.1370 0.040100 0.1110 0.5350 65.043
Viva La Vida Coldplay 78 0.485 0.6190 -7.115 0.0289 0.094100 0.1090 0.4160 138.017
Bad Romance Lady Gaga 78 0.696 0.9210 -3.755 0.0363 0.003140 0.0842 0.7140 119.001
I Knew You Were Trouble. Taylor Swift 76 0.622 0.4690 -6.798 0.0363 0.004540 0.0335 0.6790 77.019
Our Song Taylor Swift 61 0.667 0.6590 -4.932 0.0298 0.113000 0.3250 0.5750 89.128
Mean Taylor Swift 62 0.570 0.7470 -3.978 0.0426 0.445000 0.2190 0.8080 164.004
The Lazy Song Bruno Mars 73 0.738 0.8040 -3.851 0.0621 0.332000 0.2790 0.9490 174.943
Love The Way You Lie (Part II) - Pt. 2 Rihanna 65 0.472 0.8330 -4.486 0.1620 0.297000 0.0560 0.4130 166.271
Just Dance Lady Gaga 73 0.822 0.7390 -4.541 0.0311 0.026400 0.1810 0.7450 118.992
Paparazzi Lady Gaga 69 0.762 0.6920 -3.973 0.0438 0.113000 0.0940 0.3970 114.906
Alejandro Lady Gaga 8 0.626 0.7990 -6.612 0.0460 0.000358 0.3600 0.3690 98.992
Hotline Bling Drake 0 0.905 0.6170 -8.039 0.0596 0.002870 0.0484 0.5720 134.972
Adventure of a Lifetime Coldplay 74 0.638 0.9240 -3.887 0.0359 0.002050 0.1490 0.5290 111.995
Hymn for the Weekend Coldplay 77 0.490 0.7430 -5.155 0.0409 0.255000 0.3000 0.3630 89.974
I Feel It Coming The Weeknd 80 0.773 0.8190 -5.946 0.1180 0.426000 0.0679 0.5850 92.990
Paradise Coldplay 77 0.449 0.5850 -6.762 0.0268 0.052200 0.0833 0.2030 139.627
Look What You Made Me Do Taylor Swift 74 0.766 0.7090 -6.471 0.1230 0.204000 0.1260 0.5060 128.070
That’s What I Like Bruno Mars 82 0.853 0.5600 -4.961 0.0406 0.013000 0.0944 0.8600 134.066
Gorgeous Taylor Swift 67 0.800 0.5350 -6.684 0.1350 0.071300 0.2130 0.4510 92.027
Starboy The Weeknd 84 0.678 0.5880 -7.015 0.2760 0.141000 0.1370 0.4860 186.005
We Are Never Ever Getting Back Together Taylor Swift 74 0.628 0.6760 -5.911 0.0916 0.009570 0.1210 0.7500 85.984
As Long As You Love Me Justin Bieber 72 0.571 0.8730 -3.382 0.0997 0.080700 0.3610 0.6130 139.691
Mistletoe Justin Bieber 84 0.658 0.5600 -9.049 0.0467 0.498000 0.0794 0.8540 161.994
Just the Way You Are Bruno Mars 80 0.637 0.8430 -5.413 0.0432 0.015100 0.0876 0.4340 109.012
Thinking out Loud Ed Sheeran 67 0.781 0.4450 -6.061 0.0295 0.474000 0.1840 0.5910 78.998
Diamonds Rihanna 66 0.564 0.7100 -4.920 0.0461 0.001250 0.1090 0.3930 91.972
Can’t Feel My Face The Weeknd 80 0.705 0.7690 -5.526 0.0426 0.112000 0.1050 0.5900 107.939
One Dance Drake 20 0.791 0.6190 -5.886 0.0532 0.007840 0.3510 0.3710 103.989
The Hills The Weeknd 6 0.587 0.5660 -7.017 0.0528 0.084300 0.1450 0.1550 113.025
Versace On The Floor (Bruno Mars vs. David Guetta) Bruno Mars 63 0.747 0.7010 -4.902 0.0429 0.108000 0.0712 0.5890 100.012
Too Good Drake 12 0.804 0.6480 -7.805 0.1170 0.057300 0.1020 0.3920 117.983
Shake It Off Taylor Swift 18 0.648 0.7850 -5.414 0.1650 0.056100 0.1480 0.9430 160.020
Locked Out of Heaven Bruno Mars 78 0.726 0.6980 -4.165 0.0431 0.049000 0.3090 0.8670 143.994
Best I Ever Had Drake 72 0.431 0.8940 -2.673 0.3300 0.095100 0.1880 0.6040 162.193
Hymn for the Weekend - Seeb Remix Coldplay 71 0.565 0.8490 -3.516 0.0517 0.008680 0.1200 0.4270 102.034
FourFiveSeconds Rihanna 21 0.579 0.2680 -5.650 0.0442 0.868000 0.1200 0.3210 205.903
Galway Girl Ed Sheeran 80 0.624 0.8760 -3.374 0.1000 0.073500 0.3270 0.7810 99.943
Only Girl (In The World) Rihanna 8 0.768 0.7380 -3.017 0.0406 0.052400 0.0561 0.6850 125.928
We Found Love Rihanna 19 0.734 0.7660 -4.485 0.0383 0.025000 0.1080 0.6000 127.986
In My Feelings Drake 83 0.835 0.6260 -5.833 0.1250 0.058900 0.3960 0.3500 91.030
God’s Plan Drake 86 0.754 0.4490 -9.211 0.1090 0.033200 0.5520 0.3570 77.169
Passionfruit Drake 15 0.809 0.4630 -11.377 0.0396 0.256000 0.1090 0.3640 111.980
Yellow Coldplay 81 0.429 0.6610 -7.227 0.0281 0.002390 0.2340 0.2850 173.365
Fix You Coldplay 81 0.209 0.4180 -8.740 0.0338 0.163000 0.1130 0.1230 138.265
Controlla Drake 73 0.611 0.4680 -11.084 0.1790 0.078100 0.1010 0.3490 92.092
Ocean Eyes - Blackbear Remix Billie Eilish 73 0.661 0.4190 -9.807 0.0404 0.114000 0.0848 0.1450 144.980
The Scientist Coldplay 83 0.560 0.4420 -7.224 0.0243 0.727000 0.1100 0.2120 146.448
Clocks Coldplay 75 0.577 0.7490 -7.215 0.0279 0.599000 0.1830 0.2610 130.969
In My Place Coldplay 70 0.425 0.5870 -5.453 0.0278 0.056500 0.2980 0.1940 144.642
A Sky Full of Stars - Robin Schulz Edit Coldplay 51 0.638 0.8470 -5.648 0.0338 0.004050 0.4000 0.3330 123.042
What Do You Mean? Justin Bieber 78 0.845 0.5670 -8.118 0.0956 0.590000 0.0811 0.7930 125.020
Treasure Bruno Mars 76 0.874 0.6920 -5.280 0.0431 0.041200 0.3240 0.9370 116.017
Work Rihanna 77 0.725 0.5340 -6.238 0.0946 0.075200 0.0919 0.5580 91.974
What’s My Name? Rihanna 68 0.690 0.7860 -2.959 0.0692 0.229000 0.0797 0.5830 100.049
24K Magic Bruno Mars 78 0.818 0.8030 -4.282 0.0797 0.034000 0.1530 0.6320 106.970
ME! (feat. Brendon Urie of Panic! At The Disco) Taylor Swift 29 0.614 0.8390 -4.143 0.0702 0.029100 0.1120 0.6570 182.123
my boy Billie Eilish 80 0.692 0.3940 -8.745 0.2070 0.472000 0.1170 0.3240 89.936
party favor Billie Eilish 76 0.826 0.1880 -12.181 0.0883 0.882000 0.1030 0.2050 130.022
Shallow - Radio Edit Lady Gaga 78 0.575 0.3300 -6.557 0.0310 0.416000 0.0872 0.2770 95.801
bury a friend Billie Eilish 87 0.905 0.3890 -14.505 0.3320 0.740000 0.1060 0.1960 120.046
you should see me in a crown Billie Eilish 84 0.678 0.5330 -10.485 0.1860 0.462000 0.1390 0.3230 150.455
all the good girls go to hell Billie Eilish 86 0.726 0.4440 -8.922 0.3720 0.283000 0.1770 0.5690 185.044
Behind Barz - Bonus Drake 77 0.854 0.5540 -4.684 0.1720 0.769000 0.0749 0.2720 142.069
Over Drake 63 0.350 0.8450 -5.614 0.2000 0.010700 0.1230 0.4500 99.643
Money In The Grave (Drake ft. Rick Ross) Drake 88 0.831 0.5020 -4.045 0.0460 0.101000 0.1220 0.1010 100.541
Nice For What Drake 18 0.567 0.9130 -6.471 0.0736 0.093400 0.1140 0.7920 93.350
Back To Back Drake 69 0.893 0.4800 -3.728 0.3560 0.008540 0.1160 0.3820 86.976
Jumpman Drake 75 0.852 0.5530 -7.286 0.1870 0.056300 0.3320 0.6560 142.072
Forever Drake 67 0.415 0.9260 -1.304 0.3740 0.253000 0.2560 0.5420 158.423
Nonstop Drake 13 0.909 0.4050 -8.133 0.1400 0.030600 0.1050 0.4550 154.984
Bitch Better Have My Money Rihanna 75 0.781 0.7280 -4.981 0.0621 0.050900 0.2570 0.3950 102.990
Swine Lady Gaga 1 0.712 0.8610 -3.625 0.1360 0.006200 0.6340 0.2090 127.890
Needed Me Rihanna 14 0.671 0.3140 -8.091 0.2440 0.110000 0.0825 0.2960 110.898
Rude Boy Rihanna 12 0.563 0.7500 -4.496 0.1270 0.113000 0.0788 0.8120 173.906
Portland Drake 74 0.925 0.4430 -8.216 0.2640 0.017200 0.2760 0.3500 136.078
Gyalchester Drake 70 0.877 0.3910 -8.196 0.0630 0.031700 0.0945 0.1220 131.018
Can’t Have Everything Drake 60 0.856 0.5720 -8.429 0.3730 0.013600 0.1210 0.4540 82.445
Sacrifices Drake 1 0.903 0.4390 -11.813 0.3970 0.040700 0.1380 0.5320 139.112
Uptown (feat. Bun B & Lil Wayne) Drake 62 0.416 0.8240 -3.075 0.3430 0.003910 0.1040 0.4170 85.433
Started From the Bottom Drake 1 0.790 0.5400 -6.959 0.1830 0.039100 0.2660 0.4590 86.308
The Motto Drake 10 0.774 0.4310 -8.407 0.3460 0.000146 0.1120 0.3530 201.843
Hold On, We’re Going Home Drake 1 0.765 0.4520 -6.644 0.0680 0.003300 0.0916 0.3310 100.002
KMT Drake 64 0.875 0.6000 -6.818 0.0435 0.018900 0.1320 0.0906 119.987
The Hills - RL Grime Remix The Weeknd 51 0.571 0.8970 -2.463 0.0432 0.113000 0.1580 0.4460 139.996
MyBoi - TroyBoi Remix Billie Eilish 71 0.879 0.5800 -4.797 0.0883 0.006260 0.0653 0.3120 92.004
Grammys Drake 1 0.711 0.4400 -9.509 0.4710 0.001750 0.0798 0.1210 145.116
Digital Dash Drake 1 0.889 0.5430 -7.666 0.1280 0.003110 0.2340 0.3140 140.029
Always in My Head Coldplay 65 0.499 0.5020 -9.307 0.0254 0.012800 0.0680 0.0397 97.544
Magic Coldplay 72 0.738 0.4830 -8.915 0.0403 0.026200 0.1060 0.3550 93.458
Ink Coldplay 62 0.688 0.7060 -7.310 0.0324 0.066100 0.1180 0.6890 112.019
True Love Coldplay 58 0.482 0.5740 -7.963 0.0280 0.003820 0.1230 0.1840 119.994
Midnight Coldplay 64 0.548 0.4750 -12.420 0.0355 0.615000 0.0944 0.0349 126.976
Another’s Arms Coldplay 57 0.518 0.5720 -9.037 0.0291 0.007150 0.1390 0.3470 160.005
Oceans Coldplay 55 0.194 0.1320 -15.783 0.0349 0.919000 0.1590 0.0400 74.848
O Coldplay 63 0.230 0.2160 -14.727 0.0376 0.911000 0.0934 0.0618 92.022
All Your Friends Coldplay 36 0.507 0.3170 -12.177 0.0283 0.183000 0.1120 0.2010 74.980
Ghost Story Coldplay 37 0.595 0.6380 -7.941 0.0307 0.104000 0.0699 0.5100 122.005
O - Reprise Coldplay 32 0.201 0.3270 -11.975 0.0285 0.869000 0.1170 0.0945 107.019
Talk Coldplay 62 0.413 0.5570 -10.841 0.0335 0.005480 0.1550 0.1580 120.318
Trouble Coldplay 71 0.561 0.5470 -7.496 0.0321 0.189000 0.1700 0.1900 139.755
Lost! Coldplay 52 0.359 0.7790 -7.520 0.0412 0.005700 0.3790 0.5820 86.951
Beautiful People (feat. Khalid) - NOTD Remix Ed Sheeran 66 0.702 0.7940 -5.913 0.0562 0.007150 0.1100 0.3700 103.972
Starboy - Kygo Remix The Weeknd 5 0.751 0.6230 -7.215 0.0939 0.209000 0.1680 0.3830 93.010
Galway Girl - Martin Jensen Remix Ed Sheeran 58 0.726 0.7480 -4.576 0.0438 0.024500 0.1410 0.7310 100.055
Photograph - Felix Jaehn Remix Ed Sheeran 0 0.733 0.8210 -4.982 0.0407 0.081500 0.1220 0.3970 120.011
Thinking out Loud - Alex Adair Remix Ed Sheeran 49 0.828 0.7450 -6.717 0.1520 0.210000 0.0870 0.5170 117.008
Often - Kygo Remix The Weeknd 65 0.523 0.4910 -9.876 0.0491 0.123000 0.3310 0.4080 80.156
Marry You Bruno Mars 72 0.620 0.8320 -4.848 0.0360 0.332000 0.1040 0.4810 144.926
Princess of China - Acoustic Coldplay 52 0.245 0.4710 -7.952 0.0313 0.652000 0.1260 0.2870 165.996
The A Team - Acoustic Ed Sheeran 50 0.649 0.2640 -9.899 0.2800 0.727000 0.2920 0.4240 121.815
Magic - Live at the Enmore Theatre, Sydney Coldplay 54 0.500 0.5020 -11.775 0.0424 0.180000 0.7290 0.3620 93.361
A Sky Full of Stars - Live at the Royal Albert Hall, London Coldplay 54 0.467 0.7650 -7.846 0.0311 0.004160 0.7080 0.1860 125.013
Nothing On You (feat. Paulo Londra & Dave) Ed Sheeran 59 0.747 0.6490 -6.218 0.2190 0.333000 0.1720 0.8400 88.011
Somebody To Love Remix Justin Bieber 54 0.704 0.8360 -4.619 0.0283 0.003880 0.1600 0.5530 129.989
Eenie Meenie Justin Bieber 4 0.718 0.6050 -4.240 0.0307 0.044300 0.0962 0.8180 121.236
One Time Justin Bieber 68 0.691 0.8530 -2.528 0.0372 0.063100 0.0820 0.7620 145.999
One Less Lonely Girl Justin Bieber 67 0.580 0.7500 -4.421 0.1940 0.159000 0.2740 0.7280 86.938
Love Me Justin Bieber 65 0.729 0.8680 -3.319 0.0609 0.009390 0.2830 0.6320 124.957
Stupid In Love Rihanna 47 0.738 0.5620 -5.435 0.0347 0.633000 0.1020 0.4760 127.452
Grenade Bruno Mars 75 0.706 0.5580 -7.237 0.0593 0.146000 0.1180 0.2270 110.443
Hard Rihanna 56 0.310 0.7460 -3.599 0.1110 0.012100 0.6490 0.1630 182.032
Russian Roulette Rihanna 65 0.480 0.4860 -5.754 0.0447 0.046000 0.1070 0.2650 80.051
S&M Rihanna 72 0.766 0.6820 -5.020 0.0419 0.011300 0.1040 0.8330 127.966
Complicated Rihanna 48 0.710 0.8970 -3.802 0.0372 0.175000 0.0918 0.3300 137.972
Pop Style Drake 51 0.713 0.4620 -10.027 0.1230 0.192000 0.1050 0.0595 133.054
Fake Love Drake 6 0.924 0.5430 -7.474 0.2980 0.182000 0.1030 0.7360 133.907
When I Was Your Man Bruno Mars 82 0.612 0.2800 -8.648 0.0434 0.932000 0.0880 0.3870 72.795
You Belong With Me Taylor Swift 52 0.688 0.7750 -4.436 0.0381 0.151000 0.1040 0.4690 129.969
I Knew You Were Trouble Taylor Swift 16 0.499 0.4670 -6.744 0.0461 0.005930 0.0361 0.6370 76.760
Wildest Dreams Taylor Swift 65 0.553 0.6640 -7.417 0.0741 0.070900 0.1060 0.4670 140.060
Pon de Replay - Radio Edit Rihanna 34 0.750 0.6320 -8.681 0.2150 0.000147 0.1080 0.5320 98.997
Perfect Ed Sheeran 86 0.599 0.4480 -6.312 0.0232 0.163000 0.1060 0.1680 95.050
Pray For Me (with Kendrick Lamar) The Weeknd 76 0.735 0.6770 -4.979 0.0930 0.076200 0.1110 0.1880 100.584
Cross Me (feat. Chance the Rapper & PnB Rock) Ed Sheeran 73 0.746 0.7870 -6.373 0.1200 0.214000 0.0669 0.6070 95.005
The Zone The Weeknd 61 0.619 0.5210 -8.092 0.0744 0.260000 0.1010 0.2540 139.886
Till Dawn (Here Comes The Sun) The Weeknd 53 0.697 0.5420 -8.946 0.0437 0.821000 0.1340 0.5470 99.988
Same Old Song The Weeknd 55 0.771 0.5600 -5.636 0.0692 0.415000 0.5360 0.3890 109.978
Echoes Of Silence The Weeknd 55 0.214 0.1560 -17.515 0.0443 0.951000 0.1010 0.1320 75.654
Valerie The Weeknd 62 0.641 0.5390 -6.351 0.0463 0.346000 0.0837 0.4360 148.004
Gone The Weeknd 54 0.494 0.6970 -7.232 0.3090 0.708000 0.0602 0.3440 107.669
The Party & The After Party The Weeknd 60 0.438 0.6340 -7.456 0.3370 0.476000 0.1130 0.3970 203.585
Losers The Weeknd 62 0.666 0.4850 -9.850 0.0527 0.035500 0.5040 0.2880 91.009
Tell Your Friends The Weeknd 68 0.565 0.4540 -11.091 0.0461 0.265000 0.1810 0.3120 74.809
Often The Weeknd 76 0.569 0.6290 -9.837 0.0485 0.218000 0.1350 0.0726 134.035
Dark Times The Weeknd 69 0.501 0.4030 -9.607 0.0752 0.114000 0.1240 0.2700 132.608
Prisoner The Weeknd 64 0.550 0.4040 -12.755 0.0398 0.441000 0.1100 0.3290 135.016
Secrets The Weeknd 71 0.665 0.7710 -5.779 0.0533 0.015500 0.4600 0.7640 109.945
True Colors The Weeknd 69 0.624 0.4240 -8.237 0.2400 0.284000 0.1730 0.5840 76.669
Sidewalks The Weeknd 70 0.542 0.7210 -5.136 0.0625 0.147000 0.3480 0.6230 149.831
Six Feet Under The Weeknd 69 0.772 0.5040 -8.219 0.0761 0.129000 0.1250 0.2440 140.035
Die For You The Weeknd 76 0.586 0.5250 -7.163 0.0615 0.111000 0.1340 0.5080 133.629
Call Out My Name The Weeknd 24 0.449 0.5990 -4.892 0.0369 0.211000 0.3270 0.1650 134.144
Try Me The Weeknd 19 0.466 0.6720 -5.777 0.0680 0.622000 0.1470 0.1080 91.673
Wasted Times The Weeknd 18 0.562 0.6740 -6.049 0.0851 0.622000 0.1110 0.2930 122.699
I Was Never There The Weeknd 17 0.324 0.7350 -4.054 0.0337 0.135000 0.1690 0.1690 113.923
Hurt You The Weeknd 17 0.484 0.7160 -7.193 0.1670 0.300000 0.1120 0.3650 184.131
Privilege The Weeknd 16 0.391 0.5950 -7.094 0.0411 0.913000 0.1450 0.3790 93.780
Twenty Eight The Weeknd 61 0.639 0.6330 -7.338 0.0352 0.574000 0.1110 0.2430 129.996
Crew Love Drake 51 0.418 0.5460 -9.057 0.2380 0.227000 0.2290 0.2940 160.152
Get It Together Drake 69 0.781 0.7210 -9.133 0.0514 0.094500 0.1040 0.8490 123.011
Summers Over Interlude Drake 57 0.698 0.2550 -8.647 0.0303 0.405000 0.0985 0.2430 132.036
Tears In The Rain The Weeknd 43 0.655 0.6360 -7.840 0.0453 0.109000 0.0842 0.1850 160.010
Adaptation The Weeknd 44 0.642 0.7900 -6.800 0.0681 0.151000 0.3050 0.6130 114.960
Jaded Drake 68 0.766 0.2710 -5.697 0.0412 0.037000 0.1750 0.0371 116.020
Dreams Money Can Buy Drake 61 0.423 0.5870 -6.635 0.5290 0.765000 0.1140 0.3300 180.331
Feels (feat. Young Thug & J Hus) Ed Sheeran 37 0.665 0.6800 -4.899 0.2900 0.112000 0.0960 0.6900 91.670
How Bout Now Drake 66 0.789 0.4040 -8.364 0.2300 0.205000 0.2190 0.4720 122.062
Jodeci Freestyle (feat. J. Cole) Drake 57 0.498 0.8440 -2.834 0.2680 0.011100 0.1020 0.2820 88.435
Shallow Lady Gaga 88 0.572 0.3850 -6.362 0.0308 0.371000 0.2310 0.3230 95.799
I See Fire Ed Sheeran 23 0.641 0.1760 -11.692 0.0349 0.638000 0.2520 0.2970 76.031
8 Billie Eilish 80 0.735 0.2350 -13.239 0.3150 0.698000 0.1070 0.4620 62.446
i love you Billie Eilish 85 0.421 0.1310 -18.435 0.0382 0.952000 0.1090 0.1200 137.446
goodbye Billie Eilish 77 0.153 0.1380 -21.877 0.0503 0.837000 0.2540 0.0503 74.318
xanny Billie Eilish 83 0.521 0.1250 -17.832 0.2390 0.751000 0.2650 0.0528 111.554
ocean eyes Billie Eilish 85 0.511 0.3630 -7.650 0.0410 0.816000 0.0840 0.1690 144.892
Best Part of Me (feat. YEBBA) Ed Sheeran 74 0.565 0.2420 -8.367 0.0318 0.762000 0.2850 0.2370 81.657
hostage Billie Eilish 79 0.427 0.1230 -15.228 0.0497 0.868000 0.0732 0.0394 129.565
&burn (with Vince Staples) Billie Eilish 68 0.776 0.3790 -9.351 0.3310 0.213000 0.0969 0.3460 82.531
Summer Games Drake 4 0.776 0.4820 -11.268 0.0356 0.481000 0.1100 0.1280 136.015
Jungle Drake 70 0.690 0.2350 -8.651 0.0541 0.618000 0.1070 0.3780 99.906
Take Care Drake 71 0.629 0.5150 -10.358 0.2650 0.026700 0.0888 0.2990 121.845
Marvins Room Drake 74 0.492 0.2600 -17.341 0.0921 0.646000 0.0705 0.3120 111.519
lovely (with Khalid) Billie Eilish 89 0.351 0.2960 -10.109 0.0333 0.934000 0.0950 0.1200 115.284
Man Down Rihanna 59 0.479 0.9060 -4.030 0.1880 0.040600 0.0510 0.5360 155.887
idontwannabeyouanymore Billie Eilish 85 0.483 0.4120 -8.461 0.0402 0.737000 0.1160 0.2470 170.163
when the party’s over Billie Eilish 26 0.498 0.1040 -14.080 0.0621 0.979000 0.0895 0.2050 124.001
0 To 100 / The Catch Up Drake 5 0.559 0.7160 -3.964 0.3900 0.737000 0.2520 0.5040 176.618
The Language Drake 53 0.823 0.6620 -8.426 0.3180 0.011800 0.0805 0.5330 120.117
6 Man Drake 1 0.812 0.5350 -9.306 0.4490 0.217000 0.1140 0.3210 78.974
Used To Drake 0 0.926 0.4270 -7.584 0.1070 0.070300 0.0818 0.3050 96.023
No Tellin’ Drake 1 0.823 0.4670 -10.394 0.3010 0.543000 0.1350 0.6180 95.024
Purpose Justin Bieber 71 0.481 0.2850 -10.848 0.0424 0.900000 0.1230 0.3160 130.029
Bellyache - Marian Hill Remix Billie Eilish 71 0.832 0.3680 -8.627 0.1330 0.200000 0.3530 0.2000 100.045
my strange addiction Billie Eilish 82 0.939 0.3050 -10.952 0.3540 0.350000 0.1050 0.5630 100.029
ilomilo Billie Eilish 81 0.855 0.4230 -15.044 0.0585 0.724000 0.0896 0.5720 120.020
listen before i go Billie Eilish 81 0.319 0.0561 -23.023 0.0450 0.935000 0.3880 0.0820 79.764
Bored Billie Eilish 76 0.614 0.3180 -12.695 0.0478 0.896000 0.0795 0.1120 119.959
Sex With Me Rihanna 69 0.580 0.5320 -5.668 0.0424 0.294000 0.0948 0.3900 112.049
Pour It Up Rihanna 62 0.785 0.4780 -8.735 0.0419 0.025400 0.0901 0.3900 134.002
Finesse - Remix; feat. Cardi B Bruno Mars 77 0.704 0.8590 -4.877 0.0996 0.018500 0.0215 0.9260 105.115
Emotionless Drake 6 0.413 0.6760 -5.124 0.2130 0.023900 0.0811 0.0827 173.478
I Forgot That You Existed Taylor Swift 79 0.664 0.3160 -10.345 0.5190 0.298000 0.0812 0.5410 92.875
End Game Taylor Swift 68 0.649 0.5890 -6.237 0.0558 0.008450 0.1080 0.1510 159.073
Perfect Duet (Ed Sheeran & Beyoncé) Ed Sheeran 77 0.587 0.2990 -7.365 0.0263 0.779000 0.1230 0.3560 94.992
Signs Drake 70 0.794 0.7350 -4.204 0.0540 0.108000 0.1120 0.2230 107.374
Love Yourself Justin Bieber 83 0.609 0.3780 -9.828 0.4380 0.835000 0.2800 0.5150 100.418
Kiss It Better - KAYTRANADA Edition Rihanna 45 0.854 0.4980 -7.922 0.3320 0.022900 0.3000 0.3430 108.049
Higher Rihanna 1 0.292 0.5670 -4.191 0.0416 0.112000 0.1190 0.3920 153.199
James Joint Rihanna 0 0.399 0.2030 -11.649 0.0298 0.660000 0.2700 0.4050 134.202
Can’t Feel My Face - Martin Garrix Remix The Weeknd 2 0.607 0.7070 -5.509 0.1060 0.008420 0.3480 0.1170 128.014
She Don’t Like The Lights - Acoustic Version Justin Bieber 36 0.612 0.4280 -8.520 0.0292 0.750000 0.0921 0.6850 123.822
Work - R3hab Remix Rihanna 2 0.715 0.8000 -5.488 0.0555 0.010400 0.3190 0.2640 100.004
Bitch Better Have My Money - R3hab Remix Rihanna 1 0.788 0.9210 -3.210 0.0550 0.006000 0.1050 0.5510 128.007
Bitch Better Have My Money - GTA Remix Rihanna 0 0.768 0.8770 -3.114 0.1510 0.000768 0.0739 0.4800 103.036
You Need To Calm Down - Clean Bandit Remix Taylor Swift 54 0.726 0.8800 -4.137 0.0581 0.072000 0.0906 0.7390 95.037
…Ready For It? - BloodPop® Remix Taylor Swift 50 0.582 0.8350 -4.899 0.2220 0.133000 0.1020 0.4960 160.090
24K Magic - R3hab Remix Bruno Mars 59 0.763 0.7080 -5.692 0.2090 0.146000 0.3300 0.5660 106.175
Perfect - Mike Perry Remix Ed Sheeran 46 0.732 0.7560 -4.309 0.0324 0.260000 0.1300 0.3430 113.980
Kiss It Better - R3hab Remix Rihanna 1 0.728 0.7380 -3.939 0.0455 0.050500 0.1040 0.4580 102.000
Needed Me - R3hab Remix Rihanna 44 0.659 0.6830 -5.485 0.0488 0.008350 0.6250 0.2780 99.987
Paradise - Tiësto Remix Coldplay 48 0.637 0.7360 -6.003 0.0404 0.012300 0.0798 0.6430 130.015
California King Bed - Bassjackers Radio Rihanna 0 0.589 0.8210 -3.385 0.0413 0.000318 0.3900 0.1590 127.986
Shape of You - Galantis Remix Ed Sheeran 51 0.838 0.7650 -2.332 0.0462 0.051400 0.0297 0.9050 100.021
That’s What I Like - Alan Walker Remix Bruno Mars 63 0.692 0.8960 -4.017 0.0502 0.012100 0.1990 0.7980 134.056
Bad Blood Taylor Swift 62 0.652 0.8020 -6.114 0.1810 0.087100 0.1480 0.2950 170.157
Beauty And A Beat Justin Bieber 72 0.601 0.8430 -4.870 0.0593 0.000704 0.0681 0.5340 128.002
Delicate Taylor Swift 71 0.750 0.4040 -10.178 0.0682 0.216000 0.0911 0.0499 95.045
Finesse Bruno Mars 68 0.741 0.7980 -5.342 0.0718 0.007810 0.0232 0.9390 104.953
A Sky Full of Stars - Hardwell Remix Coldplay 18 0.439 0.6480 -3.643 0.0325 0.019000 0.3430 0.0546 127.954

Exemple : le top 10 Spotify

library(tidyverse)

ggplot(df, aes(x = danceability, y = energy, color = track_artist)) +
  geom_point() +
  theme_bw()

Exemple : le top 10 Spotify

library(tidyverse)

ggplot(df, aes(x = loudness, y = speechiness, color = track_artist)) +
  geom_point() +
  theme_bw()

Exemple : le top 10 Spotify

library(FactoMineR)
library(factoextra)
pca_not_scaled <- df |> select(
    danceability, energy, loudness, speechiness,
    acousticness, liveness, valence, tempo
  ) |> PCA(scale.unit = FALSE, graph = FALSE)
fviz_eig(pca_not_scaled)
get_eigenvalue(pca_scaled)

eigenvalue variance.percent cumulative.variance.percent
Dim.1 810.6332465 98.6720169 98.67202
Dim.2 10.7552317 1.3091499 99.98117
Dim.3 0.0567231 0.0069045 99.98807
Dim.4 0.0441830 0.0053781 99.99345
Dim.5 0.0210597 0.0025634 99.99601
Dim.6 0.0134860 0.0016415 99.99765
Dim.7 0.0100835 0.0012274 99.99888
Dim.8 0.0091876 0.0011183 100.00000

Exemple : le top 10 Spotify

library(FactoMineR)
library(factoextra)
pca_scaled <- df |> select(
    danceability, energy, loudness, speechiness,
    acousticness, liveness, valence, tempo
  ) |> PCA(scale.unit = TRUE, graph = FALSE)
fviz_eig(pca_scaled)
get_eigenvalue(pca_scaled)

eigenvalue variance.percent cumulative.variance.percent
Dim.1 2.8090242 35.112803 35.11280
Dim.2 1.3209372 16.511715 51.62452
Dim.3 1.1505090 14.381362 66.00588
Dim.4 0.9610515 12.013144 78.01902
Dim.5 0.6455193 8.068991 86.08801
Dim.6 0.5897927 7.372408 93.46042
Dim.7 0.3466595 4.333244 97.79367
Dim.8 0.1765066 2.206333 100.00000

Exemple : le top 10 Spotify

fviz_pca_var(
  pca_scaled,
  col.var = "cos2",
  gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"), 
  repel = TRUE # Avoid text overlapping
)

Exemple : le top 10 Spotify

fviz_contrib(pca_scaled, choice = "var", axes = 1)
fviz_contrib(pca_scaled, choice = "var", axes = 2)

Exemple : le top 10 Spotify

fviz_pca_ind(
  pca_scaled,
  geom.ind = "point", # show points only (nbut not "text")
  col.ind = df$track_artist, # color by groups
  legend.title = "Artists",
) + scale_shape_manual(values = rep(19, 10))

Exemple : le top 10 Spotify

fviz_pca_biplot(
  pca_scaled,
  repel = TRUE,
  col.var = "#2E9FDF", # Variables color
  col.ind = "#696969"  # Individuals color
)

Conclusion


L’ACP est un outil puissant pour la réduction de dimension qui :

  • Préserve l’information maximale.

  • Élimine la redondance d’information.

  • Facilite la visualisation et la modélisation.

  • Nécessite des choix méthodologiques.

Prochaine étape → Que faire si les données ne sont pas qualitatives ?