REGRESSION

Regression refers to a machine learning technique where we focus on creating a hypothesis model that tries to predict continuous values after analyzing patterns.

Hypothesis Model

hypothesis_model_sketch

Ques1: "What is this hypothesis function and how it will be created by the model?"

So to understand this we use simpler data that will help us to understand how these things work...

Regression Data Sample

Dependent Variable (given feature) Independent Variable (target)
1 6
2 12
3 18
4 24
5 30

"What are these independent variable (X) and dependent variable (y)? 😲"

"Independent Variables / features: " So anything that helps me in formulating my equation is Independent Variable. We say it as features. Too technical? Understand it by this example: "I have a cat." How will I know that this is a cat? Obviously, we know by their features: spooky eyes, meow sound, rat killer, right? In the same way, features are important for prediction. From this example, you also understand that correct selection of features improves my algorithm...

"Dependent Variable / Target: " My prediction values. If we consider the same example, after getting all the info about eyes, tail, sound, and other things, it will help me to categorize whether this animal is a cat or not, right? So the prediction of whether it is a cat or not is my dependent feature. As the output is completely dependent on features, that's why we call it a Dependent variable.

"First understand what hypothesis is?" Hypothesis in case of regression just means to establish a mapping function. Think of like creating F(x) or y for every x that responds closer to actual output.

If we have to create a hypothesis, according to me, my first step is to understand the relationship between variables, right? So let's have a look at the scatterplot of the given data.

Have you noticed something? We can think of the equation for the given data as: y = 6.00x + 0.00

"I know you are confused how I am doing this, I will tell you in the upcoming journey."

If you have analyzed it, machine algorithms are working in the same way as human minds interpret. I know that we get stressed with complex calculations. Can we say that's why ML is introduced? It's somehow like I know how my mind works, and then I formulate the process of minds toward a problem and use machines to generalize this process in various tasks. Right? I am also amazed at how cool our scientists and engineers are...

My hypothesis function always try to formulate equation in terms of y = m x + c

Types of Regression

There are multiple models for regression anlysis. But broadly we can categorize them into 3 parts ::

Understanding How Algorithms Reach the Best Fit Line

In machine learning, the journey to finding the optimal fit line is intriguing! Let's explore how we minimize error to achieve this.

Concept of Squared Error Function

Imagine you're trying to walk to a certain point but don't know the exact distance. The key question is: how do you figure out how far you need to walk to reach your destination? In machine learning, we calculate how far off our predictions are from the actual values. This is where the squared error function comes in.

We calculate the difference between predicted and actual points, square it to ensure all errors are positive, and sum these squared differences to obtain the total error or "cost." Our goal is to minimize this total cost by adjusting the model's parameters, gradually getting closer to the best fit line.

Squared Error Minimization & Gradient Descent

Explore how we minimize the squared error between actual and predicted points!

Input Data

X Value Actual Y Value Predicted Y Value
Overall Loss (MSE): Calculating...

Gradient Descent Animation

Understanding the Impact of Learning Rate in Gradient Descent

The learning rate is a critical hyperparameter in the journey of gradient descent. Let's explore how different learning rates affect convergence!

Concept of Learning Rate

In gradient descent, the learning rate determines the size of the steps taken towards the minimum of the loss function. If the learning rate is too high, we may overshoot the minimum, while a very low learning rate can lead to a long convergence time.

Learning Rate and Gradient Descent

Visualize how different learning rates impact the optimization process!

Set Your Learning Rate

0.01
Current Learning Rate: 0.01

Convergence Algorithm

Repeat until convergence: θj:=θjαθjJ(θ0,θ1)

Where:

  • θ = Parameters of the model
  • α = Learning rate
  • ∇J(θ) = Gradient of the cost function