0Pricing
Data Science Academy · Lektion

Pearson oder Spearman

Lineare Beziehungen und Rangkorrelationen

Pearson oder Spearman ist eine kostenlose Data Science Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Data Science Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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

Häufig gestellte Fragen

Ist die Lektion „Pearson oder Spearman“ kostenlos?

Ja — der vollständige Text von „Pearson oder Spearman“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Data Science Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Pearson oder Spearman“?

Lineare Beziehungen und Rangkorrelationen Du übst Data Science Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Data Science Academy zu starten?

Keine Vorkenntnisse erforderlich. Data Science Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „Pearson oder Spearman“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Data Science Academy-Lektion Code schreiben und ausführen?

Ja. Jede Data Science Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Korrelation ist keine Kausalität
  2. Pearson oder Spearman
  3. Eine Korrelations-Heatmap lesen
  4. Schiefe, Kurtosis und Normalverteilung
← Zurück zu Data Science Academy