A simple implementation of polynomial regression of order 2 in Flutter
The theory is very well explained here.
The matrix form co-efficient of Polynomial Regression of order m is shown as below
Incase of Quadratic regression or Polynomial regression with m=2 it becomes —
I am using the linear algebra package linalg for this purpose.
I defined a function that will take a list of y values. x values will be taken from 0 to (length of the list -1) and also a list of x values for prediction.
// input = [20, 32, 40, 34, 56]
// imput is basically (0,20),(1,32),(2,40),(3,34),(4,56)
// predictionFor = [5, 6]