0Pricing
Data Science Academy · درس

التحقق المتقاطع K-Fold

حساب متوسط الدرجات عبر الطيات

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

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

One Split, One Worry

A single train/test split gives just one score. If that split was lucky or unlucky, your estimate could be misleading.

The Big Idea

Cross-validation reuses your data many times, testing on a different slice each round, then averages the scores for a steadier estimate.

Cut Into Folds

You chop the data into k equal parts called folds. A common choice is five folds, giving five separate test rounds.

Rotate the Test Fold

Each round, one fold becomes the test set and the other k minus one folds train the model. Then the test fold rotates to the next one.

Everyone Gets a Turn

Over k rounds, every row is tested on exactly once and trained on the rest of the time. No data is wasted. 🔄

Average the Scores

You end with k scores, one per fold. Their average is your headline estimate, and their spread shows how stable the model is.

The Quick Way

scikit-learn does the looping for you. The helper cross_val_score returns one score per fold in a single line.

from sklearn.model_selection import cross_val_score
scores = cross_val_score(model, X, y, cv=5)

Read the Result

The returned array holds each fold's score. Take its mean for the headline and its standard deviation to gauge reliability.

print(scores.mean(), scores.std())

Choosing k

Five or ten folds are typical. More folds train on more data per round but cost more compute, so it is a speed-versus-stability trade.

Keep Classes Balanced

For classification, use StratifiedKFold so each fold mirrors the overall class balance. scikit-learn applies it automatically for classifiers.

Hold Out a Final Test

Cross-validation guides model choice during development. Still keep one untouched test set aside for a single honest score at the very end.

Quick Check

In 5-fold cross-validation, how often is each row tested?

Recap

Split into k folds, rotate the test fold, and average the scores for a robust estimate. Use cross_val_score, then a final hold-out. 🔄

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

هل درس «التحقق المتقاطع K-Fold» مجاني؟

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

ماذا ستتعلم في «التحقق المتقاطع K-Fold»؟

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

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

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

كم من الوقت يستغرق درس «التحقق المتقاطع K-Fold»؟

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

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

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

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

  1. لماذا نحتفظ بمجموعة اختبار منفصلة
  2. استخدام train_test_split بالشكل الصحيح
  3. التحقق المتقاطع K-Fold
  4. أوقف تسرّب البيانات قبل أن يبدأ
← العودة إلى Data Science Academy