Skip to content

anas-araid/supervised-linear-regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Supervised Linear Regression

Simple Linear Regression is finding the best relationship between the input variable x (independent variable) and the expected variable y (dependent variable). The linear relationship between these two variables can be represented by a straight line called regression line.

graph

The variable y is linearly dependent on the variable x. So, we can find a straight line which can best define the data.

This model could be applied to these following situations, for example estimating:

  • Total sales based on money spent on advertising
  • Salary based on years of experience
  • Muscle strength by body mass
  • Cholesterol level by physical exercise (in mins)

ecc...

OLS

To calculate the regression line you can use the Ordinary Least Squares regression (metodo dei minimi quadrati):

OLS

Example

Example

Y(predict value)=a(0.135)+b(0.627)*X(UserInput)

LinearRegression.js

How to use

// inital datasets for training 
var x = [1, 2, 3]; // inputs
var y = [123, 4234, 435345]; // expected values
var test = new LinearRegression(x, y);
test.predict(6);

Authors

About

supervised linear regression from scratch in javascript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published