0Pricing
Data Science Academy · درس

إعادة أخذ العينات: SMOTE وتقليل العينات

إعادة موازنة مجموعة التدريب

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

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

Rebalance the Training Set

One way to help a model see the rare class is to resample: change how many examples of each class it trains on.

Two Directions to Balance

You can add more of the minority (oversample) or trim the majority (undersample). Both aim to even out the class counts.

Naive Oversampling

The simplest oversample just copies minority rows until counts match. It works, but those exact duplicates can make a model memorize them.

Enter SMOTE

SMOTE creates synthetic minority examples instead of copies. It invents new, plausible points between real minority neighbors.

How SMOTE Builds Points

SMOTE picks a minority row, finds a nearby minority neighbor, and places a fresh point somewhere on the line between them.

SMOTE in Code

The imbalanced-learn library makes SMOTE a two-line affair on your training features and labels.

from imblearn.over_sampling import SMOTE
X_res, y_res = SMOTE().fit_resample(X_train, y_train)

Undersampling the Majority

Undersampling drops majority rows until balance returns. It trains faster but throws away data, which can cost real signal.

When to Pick Which

Oversample when data is scarce and every row matters. Undersample when the majority is huge and you can spare some rows for speed.

The Cardinal Rule

Resample only the training set. Touch the test set and your scores become fantasy, since real data is never rebalanced for you.

Fit on Train Only

SMOTE must learn from training rows alone. Leaking test rows into resampling inflates results and quietly causes data leakage. ⚠️

Resampling Is Not a Cure-All

Balanced counts help, but they are not magic. Pair resampling with the right metrics and sometimes class weights for the best results.

Quick Check

What makes SMOTE different from plain oversampling?

Recap

Resampling balances the training set by oversampling (SMOTE makes synthetic rows) or undersampling. Never resample the test set. 🎯

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

هل درس «إعادة أخذ العينات: SMOTE وتقليل العينات» مجاني؟

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

ماذا ستتعلم في «إعادة أخذ العينات: SMOTE وتقليل العينات»؟

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

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

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

كم من الوقت يستغرق درس «إعادة أخذ العينات: SMOTE وتقليل العينات»؟

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

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

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

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

  1. لماذا تكذب الدقة عند عدم التوازن
  2. إعادة أخذ العينات: SMOTE وتقليل العينات
  3. أوزان الفئات والعتبات
  4. اختيار مقاييس للأحداث النادرة
← العودة إلى Data Science Academy