Linear Regression clearly Explained!
Linear Regression models relationship bitheen a dependant variable (y) & two or more independent variables (x1, x2 ...)
❗️ For the sake of simplicity we discuss linear regression with a single independent variable.
Mathematical Representation:
y=mx+c
where:
- y is the dependent variable
- x is the independent variable
- m is the slope of the line
- c is the y intercept
Cost Function:
❗️The goal is to find the best values for m and c that minimize the error between the predicted values & the actual values for all data points.
This is how the cost function looks, a mean squared error:
MSE= 1/N∑(yi−(m*xi+c))**2
Where:
- N is the number of data points.
- yi is the actual value for the ith data point.
- mxi+c is the predicted value for the ith data point.
How it works (Optimisation)❓
To minimize the MSE, we can use gradient descent.
The basic idea is to:
- Start with some initial value of m & c
- Compute the gradient of the MSE w.r.t. both m & c.
- Update m & c in the direction of the negative gradient.
Implementation from Scratch:
Now that we understand how things work it's fairly simple to implement linear regression in Python!
Check this out 👇
That's a wrap!
If you interested in:
- Python 🐍
- ML/MLOps 🛠
- CV/NLP 🗣
- LLMs 🧠
- AI Engineering ⚙️
Find me → @akshay_pachaar ✔️
Everyday, I share tutorials on above topics!
I also write a weekly Newsletter on AI Engineering, link in the next tweet!
Cheers!! 🥂
..
لطلاب الحاسب
أنت في عطلة صيفية
لا تتوقف
لا تتوقف
لا تتوقف عن تطوير ذاتك
الاستمرار في تعلم البرمجة يقودك إلى الإحتراف .
هنا مصادر للحصول على أرقى الشهادات المجانية من جامعة هارفارد
إحفظ اااااا وشارك الفائدة للزملاء
وكمان بعضنا اذا وقف على كلمة ما عرف معناها يحفظها حفظ زي ما هي و هذا خطأ، لانو المادة ماهي حفظ وبس، تعتمد على الفهم كمان، فا مثلاً ليه ما نروح نجرب نبحث ونتوسع عن معناها ؟