Josep Ferrer Profile picture
Dec 24, 2023 โ€ข 11 tweets โ€ข 4 min read โ€ข Read on X
Struggling with Machine Learning algorithms? ๐Ÿค–

Then you better stay with me! ๐Ÿค“

Today I am starting a new series of threads to simplify ML algorithms.
...and Linear Regression is the first one! ๐Ÿ‘‡๐Ÿป Image
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. Image
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. Image
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. Image
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. Image
โœš ๐—•๐—ข๐—ก๐—จ๐—ฆ
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. Image
5๏ธโƒฃ ๐—˜๐—ฉ๐—”๐—Ÿ๐—จ๐—”๐—ง๐—œ๐—ข๐—ก
The most used metrics are:
- Coefficient of Determination or R-Squared (R2)
- Root Mean Squared Error (RSME) Image
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. Image
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)

RT the tweet below to help me share the word! :D

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Josep Ferrer

Josep Ferrer Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @rfeers

Dec 21, 2024
Logistic Regression clearly explained ๐Ÿ‘‡๐Ÿป Image
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. Image
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. Image
Read 13 tweets
Dec 18, 2024
Linear Regression clearly explained ๐Ÿ‘‡๐Ÿป Image
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. Image
Read 12 tweets
Dec 3, 2024
๐Ÿš€ New to SQL?

Hereโ€™s a roadmap to get you started, step-by-step! ๐Ÿงต๐Ÿ‘‡

(Don't forget to bookmark for later!! ๐Ÿ˜‰ ) Image
1. ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—•๐—ฎ๐˜€๐—ถ๐—ฐ๐˜€
Before diving deep, it's essential to grasp what is SQL.

Begin with:
โ€ข What is a Relational Database?
โ€ข Comparing SQL and NoSQL Databases
โ€ข Understanding SQL Syntax and Basic Commands
If you like this thread, go check the original articleโ€ผ๏ธ

๐Ÿ‘‰๐Ÿป databites.tech/p/getting-starโ€ฆ
Read 19 tweets
Nov 11, 2024
How Python work in our computer clearly explained๐Ÿ‘‡๐Ÿป Image
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. ๐Ÿข Image
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. ๐Ÿ“ฆโœจ Image
Read 10 tweets
Nov 10, 2024
Today let's learn SQL's execution order and its importance ๐Ÿ‘‡๐Ÿป Image
1๏ธโƒฃ ๐—ฆ๐—ค๐—Ÿ ๐—”๐—ฆ ๐—” ๐——๐—˜๐—–๐—Ÿ๐—”๐—ฅ๐—”๐—ง๐—œ๐—ฉ๐—˜ ๐—Ÿ๐—”๐—ก๐—š๐—จ๐—”๐—š๐—˜
๐˜ ๐˜ฐ๐˜ถ ๐˜ต๐˜ฆ๐˜ญ๐˜ญ ๐˜ช๐˜ต ๐˜ธ๐˜ฉ๐˜ข๐˜ต ๐˜บ๐˜ฐ๐˜ถ ๐˜ธ๐˜ข๐˜ฏ๐˜ต, ๐˜ฏ๐˜ฐ๐˜ต ๐˜ฉ๐˜ฐ๐˜ธ ๐˜ต๐˜ฐ ๐˜ฅ๐˜ฐ ๐˜ช๐˜ต.

So SQL expects statements to be written in a specific orderโ€Š...

but their evaluation sequence differs. Image
2๏ธโƒฃ ๐—ฆ๐—ค๐—Ÿ ๐—ค๐—จ๐—˜๐—ฅ๐—ฌ ๐—ฆ๐—ง๐—ฅ๐—จ๐—–๐—ง๐—จ๐—ฅ๐—˜
The most common SQL query structure looks just like follows. Image
Read 13 tweets
Nov 9, 2024
SQL Joins clearly explained ๐Ÿ‘‡๐Ÿป Image
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. Image
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. Image
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(