0Pricing
Data Science Academy · درس

تدريب انحدار خطي

مثال كامل من البداية إلى النهاية

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

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

A Line Through Data

Linear regression fits a straight-line relationship between your features and a numeric target. It is the classic first model for a reason. 📈

Import the Model

The estimator lives in the linear_model module. You import it once and reuse it for any regression task you meet.

from sklearn.linear_model import LinearRegression

Create an Instance

Build a fresh model by calling the class. This blank estimator holds default settings and has not seen any data yet.

model = LinearRegression()

Fit on Training Data

Now teach it with your features and target. During fit, the model finds the best line through your training points.

model.fit(X_train, y_train)

Read the Slope

Each feature gets a coefficient stored in coef_. It tells you how much the prediction moves when that feature rises by one.

model.coef_

Read the Intercept

The intercept is the prediction when every feature is zero. It anchors the line and is stored in intercept_ after fitting.

model.intercept_

Make Predictions

Hand new feature rows to predict and you get numeric estimates back, one per row, computed straight from the fitted line.

y_pred = model.predict(X_test)

The Equation Behind It

Under the hood, each prediction is just features times coefficients plus the intercept. Simple math, surprisingly powerful results.

One Feature or Many

The same call handles a single feature or dozens. With many inputs it fits a hyperplane, but your code stays exactly the same.

Linear Means a Straight Fit

Linear regression assumes a roughly straight relationship. If the pattern curves sharply, this model will underfit and miss it.

The Full Workflow

Import, create, fit, predict: four steps and you have a working regressor. This same rhythm repeats for every model you learn next.

Quick Check

Which attribute holds the per-feature weights after fitting?

Recap

You imported, created, fit, and predicted with a linear regression. Its coef_ and intercept_ even reveal what it learned. 🚀

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

هل درس «تدريب انحدار خطي» مجاني؟

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

ماذا ستتعلم في «تدريب انحدار خطي»؟

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

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

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

كم من الوقت يستغرق درس «تدريب انحدار خطي»؟

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

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

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

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

  1. عقد fit وpredict
  2. الميزات X والهدف y
  3. تدريب انحدار خطي
  4. قيّم نموذجك الأول
← العودة إلى Data Science Academy