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

Mar 15
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 13 tweets
Mar 13
The Transformer's encoder clearly explained πŸ‘‡πŸ» Image
1️⃣ π—ͺ𝗛𝗔𝗧'𝗦 π—§π—›π—˜ π—˜π—‘π—–π—’π——π—˜π—₯? 🧠

The Encoder is the part responsible for processing input tokens through self-attention and feed-forward layers to generate context-aware representations.

πŸ‘‰ It’s the powerhouse behind understanding sequences in NLP models. Image
Are you enjoying this post?

Then join my newsletter DataBites to get all my content right to your mail every week! 🧩

πŸ‘‰πŸ» databites.tech
Read 16 tweets
Feb 21
Logistic Regression clearly explained with visualsπŸ‘‡πŸ»

(Don't forget to bookmark for later! πŸ˜‰)
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 14 tweets
Feb 8
Linear Regression clearly explained with visualsπŸ‘‡πŸ»

(Don't forget to bookmar for later! πŸ˜‰)
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
Jan 29
Today let's exemplify SQL's execution order with a simple queryπŸ‘‡πŸ»

(Don't forget to bookmark for later! πŸ˜‰) Image
1️⃣ 𝗦𝗧𝗔π—₯π—§π—œπ—‘π—š 𝗙π—₯𝗒𝗠 𝗒𝗨π—₯ π—₯𝗔π—ͺ π—§π—”π—•π—Ÿπ—˜
We use a dummy table with the salary of employees depending on their field and experience,

🎯 Our main goal?
Understand the field that earns the most. Image
Go read the whole article now! πŸ‘‡πŸ»
databites.tech/p/mastering-sq…
Read 14 tweets
Jan 12
Ever felt confused by SQL's execution flow? πŸ€”

Then you better stay with me!

Today let's exemplify SQL's execution order with a simple queryπŸ‘‡πŸ» Image
1️⃣ 𝗦𝗧𝗔π—₯π—§π—œπ—‘π—š 𝗙π—₯𝗒𝗠 𝗒𝗨π—₯ π—₯𝗔π—ͺ π—§π—”π—•π—Ÿπ—˜
We use a dummy table with the salary of employees depending on their field and experience,

🎯 Our main goal?
Understand the field that earns the most. Image
2️⃣ π—¦π—€π—Ÿ π—€π—¨π—˜π—₯𝗬 𝗦𝗧π—₯𝗨𝗖𝗧𝗨π—₯π—˜ (to use)
We define a query to obtain our goal data. Image
Read 13 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!

:(