Today I am starting a new series of threads to simplify ML algorithms.
...and Linear Regression is the first one! ๐๐ป
Linear regression is the simplest statistical regression method used for predictive analysis.
It can be performed with multiple variables.... but today we'll focus on a single one.
Also known as Simple Linear Regression.
1๏ธโฃ ๐ฆ๐๐ ๐ฃ๐๐ ๐๐๐ก๐๐๐ฅ ๐ฅ๐๐๐ฅ๐๐ฆ๐ฆ๐๐ข๐ก
In Simple Linear Regression, we use one independent variable to predict a dependent one.
The main goal? ๐ฏ
Finding a line of best fit.
It's simple yet powerful, revealing hidden trends in data.
2๏ธโฃ ๐๐ข๐ช ๐๐ข๐๐ฆ ๐๐ง ๐ช๐ข๐ฅ๐?
Linear regression takes advantage of a line to calculate the slope (A) and intercept (B).
We need:
- A dependent and an independent variable.
- A linear dependency between them.
3๏ธโฃ ๐๐ข๐ช ๐๐ข ๐ช๐ ๐๐๐๐๐ก๐ ๐ง๐๐ ๐๐๐ฆ๐ง ๐๐๐ง?
The best-fit line is the line that presents the least error.
Huh? ๐ค
well...
Errors are the difference between:
- Observed values of the dependent variable
- The predicted ones
With this definition, we get the error.
4๏ธโฃ ๐๐ข๐ช ๐๐ข ๐ช๐ ๐ข๐๐ง๐๐๐ก ๐๐ง ๐ ๐๐ง๐๐๐ ๐๐ง๐๐๐๐๐๐ฌ?
We use a cost function that helps us work out the optimal values for A and B.
In linear regression, this cost function is Mean Squared Errors (MSE).
It is the average of the squared errors.
โ ๐๐ข๐ก๐จ๐ฆ
To find our optimal solutions, we use the gradient descent.
It is one of the optimization algorithms that optimizes the cost function.
To obtain the optimal solution, we need to reduce MSE for all data points.
Iteratively we get closer to the optimal solution.
5๏ธโฃ ๐๐ฉ๐๐๐จ๐๐ง๐๐ข๐ก
The most used metrics are:
- Coefficient of Determination or R-Squared (R2)
- Root Mean Squared Error (RSME)
6๏ธโฃ ๐๐ฆ๐ฆ๐จ๐ ๐ฃ๐ง๐๐ข๐ก๐ฆ ๐ง๐ข ๐๐ฃ๐ฃ๐๐ฌ ๐๐ง
Linear Regression isn't just about drawing lines. It assumes certain conditions like linearity, independence, and normal distribution of residuals.
Ensuring these make our model more reliable.
And this is all for now... next week I will exemplify this model with a project, so stay tuned! ๐ค
Linear Regression is more than just a statistical method.
It's the simplest tool that helps us predict and understand our world better.
And that's all for now
If you liked this thread, I am sharing Data Science and AI content.
So don't forget to follow me to get more content like this! (@rfeers)
1๏ธโฃ ๐๐ข๐๐๐ฆ๐ง๐๐ ๐ฅ๐๐๐ฅ๐๐ฆ๐ฆ๐๐ข๐ก
It is a binary classification model used to classify our input data into two main categories.
It can be extended to multiple classifications... but today we'll focus on a binary one.
Also known as Simple Logistic Regression.
2๏ธโฃ ๐๐ข๐ช ๐ง๐ข ๐๐ข๐ ๐ฃ๐จ๐ง๐ ๐๐ง?
The Sigmoid Function is our mathematical wand, turning numbers into neat probabilities between 0 and 1.
It's what makes Logistic Regression tick, giving us a clear 'probabilistic' picture.
Linear regression is the simplest statistical regression method used for predictive analysis.
It can be performed with multiple variables.... but today we'll focus on a single one.
Also known as Simple Linear Regression.
1๏ธโฃ ๐ฆ๐๐ ๐ฃ๐๐ ๐๐๐ก๐๐๐ฅ ๐ฅ๐๐๐ฅ๐๐ฆ๐ฆ๐๐ข๐ก
In Simple Linear Regression, we use one independent variable to predict a dependent one.
The main goal? ๐ฏ
Finding a line of best fit.
It's simple yet powerful, revealing hidden trends in data.
How Python work in our computer clearly explained๐๐ป
1๏ธโฃ ๐ ๐ฒ๐บ๐ผ๐ฟ๐ ๐ฆ๐ต๐ฒ๐น๐๐ฒ๐: ๐ช๐ต๐ฒ๐ฟ๐ฒ ๐ฃ๐๐๐ต๐ผ๐ป ๐ฆ๐๐ผ๐ฟ๐ฒ๐ ๐๐ฎ๐๐ฎ
Imagine your computer's memory as a vast warehouse of shelves.
Each byte is a slot on these shelves.
Python, with your OS's permission, uses this space for its data and code. ๐ข
2๏ธโฃ ๐ฃ๐๐๐ต๐ผ๐ป ๐ข๐ฏ๐ท๐ฒ๐ฐ๐๐: ๐ง๐ต๐ฒ ๐ ๐ฎ๐ด๐ถ๐ฐ ๐๐ผ๐ ๐ฒ๐
In Python, everything is an object - from simple booleans to complex data structures.
These objects are like boxes on our memory shelves, each with a type, unique ID, value, and reference count. ๐ฆโจ
1๏ธโฃ ๐๐ฒ๐ณ๐ ๐๐ผ๐ถ๐ป
Left Join returns all records from the left table (A) and the matched records from the right table (B). If there's no match, the result is NULL on the right side.
๐กThink of it as keeping all items in A and filling gaps from B where they exist.
2๏ธโฃ ๐๐ฒ๐ณ๐ ๐๐ผ๐ถ๐ป ๐๐ถ๐๐ต๐ผ๐๐ ๐ข๐๐ฒ๐ฟ๐น๐ฎ๐ฝ๐ฝ๐ถ๐ป๐ด
This variation of Left Join returns all records from the left table (A) that don't match in B.
๐ก Ideal for finding exclusive entries in A not present in B.