عقد fit وpredict
واجهة API المشتركة بين كل المقدّرات
عقد fit وpredict درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Meet the Estimator
In scikit-learn, every model is an estimator: one object you create, teach, and then ask for answers. Same shape, every time. 🤖
Two Verbs to Remember
The whole library rests on two methods: fit to learn from data, and predict to use what it learned. Master these and you can use almost any model.
fit Means Learn
Calling fit shows the model your examples so it can find patterns. Nothing is predicted yet, the model is simply studying the data.
model.fit(X, y)predict Means Answer
Once trained, predict takes fresh inputs and returns the model's best guesses. This is where the learning finally pays off.
predictions = model.predict(X_new)One Consistent Contract
This fit-then-predict pattern is a contract every estimator honors. Swap a tree for a linear model and your code barely changes.
Create Before You Train
You always build the estimator first, often with settings, before any data touches it. That blank model is ready to learn.
from sklearn.linear_model import LinearRegression
model = LinearRegression()Order Always Matters
You must fit before you predict. Asking an untrained model for answers raises an error, since it has learned nothing yet.
fit Returns the Model
The fit call also returns the model itself, so you can chain steps in one line when you want compact, readable code.
model = LinearRegression().fit(X, y)Learned State Lives Inside
After fitting, the model stores what it learned in attributes ending with an underscore, like coef_. They appear only once training is done.
model.coef_Same API, Many Models
Because the API is shared, you can try several models by changing one line. The fit and predict calls stay identical.
from sklearn.tree import DecisionTreeRegressor
model = DecisionTreeRegressor()Why This Design Wins
One predictable interface means less to memorize and faster experiments. You focus on the problem, not on each library's quirks.
Quick Check
Let's lock in the core contract every estimator follows.
Recap
Every estimator follows one contract: create it, call fit to learn, then predict to answer. One pattern unlocks the whole library. 🎯
الأسئلة الشائعة
هل درس «عقد fit وpredict» مجاني؟
نعم — نص درس «عقد fit وpredict» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.
ماذا ستتعلم في «عقد fit وpredict»؟
واجهة API المشتركة بين كل المقدّرات تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟
لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «عقد fit وpredict»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟
نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- عقد fit وpredict
- الميزات X والهدف y
- تدريب انحدار خطي
- قيّم نموذجك الأول