项目作者: asdf1899

项目描述 :
📈 Machine learning supervised linear regression from scratch in javascript
高级语言: JavaScript
项目地址: git://github.com/asdf1899/supervised-linear-regression.git
创建时间: 2019-04-02T22:12:55Z
项目社区:https://github.com/asdf1899/supervised-linear-regression

开源协议:

下载


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

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

Authors