0Pricing
Data Science Academy · Leçon

Pearson ou Spearman

Relations linéaires ou fondées sur les rangs

Pearson ou Spearman est une leçon Data Science Academy gratuite sur CoddyKit. Ceci est la leçon 2 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Data Science Academy, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Data Science Academy comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

Two Ways to Correlate

Not all correlation is the same. The two most common methods, Pearson and Spearman, ask slightly different questions about how your variables relate. 🔍

What Pearson Measures

Pearson measures how well a straight line fits your data. It is the classic choice when both variables are numeric and their relationship looks roughly linear.

r = df["income"].corr(df["spending"], method="pearson")
print(round(r, 2))

Pearson Needs Linearity

Because Pearson only sees lines, a strong but curved relationship can trick it. If the pattern bends, the Pearson value may look weak even when a real link exists.

Pearson and Outliers

Pearson is also sensitive to outliers. A single extreme point can drag the coefficient up or down and paint a misleading picture of your data.

What Spearman Measures

Spearman works on the ranks of your values, not the raw numbers. It asks whether one variable tends to increase as the other increases, in any consistent order.

r = df["rank_a"].corr(df["rank_b"], method="spearman")
print(round(r, 2))

Monotonic Relationships

Spearman captures any monotonic trend, even a curved one. As long as the direction stays consistent, it reports a strong score regardless of the exact shape.

Robust to Outliers

Since Spearman uses ranks, one wild value barely matters. That makes it more robust when your data has extremes that would shake Pearson.

Spearman and Ordinal Data

Spearman shines with ordinal data like satisfaction ratings or rankings, where order matters but the gaps between levels are not truly equal.

When Both Agree

If a relationship is linear and outlier-free, Pearson and Spearman land close together. A big gap between them is a useful signal to look closer.

Choosing Between Them

Reach for Pearson on clean, linear numeric data. Switch to Spearman when you have ranks, curves, or outliers that you do not want to dominate the result.

One Method Argument

In pandas you switch with one argument. Pass method as either pearson or spearman to corr, and the rest of your code stays exactly the same.

Quick Check

Your data has a strong curved trend and a few wild outliers. Which method fits best?

Recap

Pearson measures linear strength on raw numbers, while Spearman ranks values to catch monotonic trends and shrug off outliers. Match the method to your data. ✅

Questions Fréquemment Posées

La leçon « Pearson ou Spearman » est-elle gratuite ?

Oui — le texte complet de « Pearson ou Spearman » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Data Science Academy, passe à CoddyKit PRO. Le cours Data Science Academy comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Pearson ou Spearman » ?

Relations linéaires ou fondées sur les rangs Tu pratiques Data Science Academy avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer Data Science Academy ?

Aucune expérience préalable n'est requise. Data Science Academy sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 2 sur 4.

Combien de temps prend la leçon « Pearson ou Spearman » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon Data Science Academy ?

Oui. Chaque leçon Data Science Academy inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Corrélation ne signifie pas causalité
  2. Pearson ou Spearman
  3. Lire une carte thermique des corrélations
  4. Asymétrie, kurtosis et normalité
← Retour à Data Science Academy