0Pricing
Data Science Academy · درس

Pearson في مقابل Spearman

العلاقات الخطية في مقابل علاقات الرتب

Pearson في مقابل Spearman درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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

الأسئلة الشائعة

هل درس «Pearson في مقابل Spearman» مجاني؟

نعم — نص درس «Pearson في مقابل Spearman» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.

ماذا ستتعلم في «Pearson في مقابل Spearman»؟

العلاقات الخطية في مقابل علاقات الرتب تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟

لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «Pearson في مقابل Spearman»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟

نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. الارتباط ليس سببية
  2. Pearson في مقابل Spearman
  3. قراءة خريطة الارتباط الحرارية
  4. الالتواء والتفرطح والتوزيع الطبيعي
← العودة إلى Data Science Academy