Intereactive Linear Regression

An interactive web application which shows the real-time calculation of a best-fit line

What is linear regression?

Linear regression is a fundamental statistical and machine learning technique used to model the relationship between a dependent variable (also called the target or output) and one or more independent variables (also called features or predictors). The goal of linear regression is to find the best-fitting straight line that minimizes the sum of the squared differences between the actual and predicted values.

In its simplest form, linear regression with a single independent variable (simple linear regression) is represented as:

The main objective in linear regression is to find the optimal values of b0 and b1 that minimize the sum of squared errors (SSE) between the actual and predicted values. This can be done using various optimization techniques, such as the normal equation, gradient descent, or least squares method.

How was this application built?

This application was built using the tensorflow-js library.
The tensorflow-js library enables us to easily make optimization algorithms. For example: we can call the stocastic gradient descent with learning rate = 0.5 using just two lines of code

The loss function is Mean Square Error (MSE). Which is the sum of the squared differences between the observed dependent variable and the values predicted by the linear model

As the objective of our optimizer is to reduce the loss function, everytime a new point is added, the optimizer function calculates the new parameter values