📈 Machine learning supervised linear regression from scratch in javascript
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.
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:
ecc…
To calculate the regression line you can use the Ordinary Least Squares regression (metodo dei minimi quadrati):
Y(predict value)=a(0.135)+b(0.627)*X(UserInput)
// 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);