emel v0.3.0 Emel.Ml.LinearRegression View Source
A linear approach to modelling the relationship between a dependent variable and one or more independent variables.
Link to this section Summary
Functions
Returns the linear function that predicts the value of the dependent variable
The set of predictor function’s coefficients based on observations (points
)
Link to this section Functions
Returns the linear function that predicts the value of the dependent variable.
Examples
iex> f = Emel.Ml.LinearRegression.predictor([%{x1: 1.794638, x2: 15.15426 , y: 5.10998918E-1},
...> %{x1: 3.220726, x2: 229.6516 , y: 105.6583692 },
...> %{x1: 5.780040, x2: 3.480201e+3, y: 1.77699E3 }],
...> [:x1, :x2], :y)
...> f.(%{x1: 3.0, x2: 230.0})
106.74114058686602
The set of predictor function’s coefficients based on observations (points
).
Examples
iex> Emel.Ml.LinearRegression.regression_coefficients([[1.794638, 15.15426 , 5.10998918E-1],
...> [3.220726, 229.6516 , 105.6583692 ],
...> [5.780040, 3.480201e+3, 1.77699E3 ]])
{:ok, [0.00834962613023635, -4.0888400103672184, 0.5173883086601628]}
iex> Emel.Ml.LinearRegression.regression_coefficients([[1.0, 1.0 ],
...> [2.0, 2.0 ],
...> [3.0, 1.3 ],
...> [4.0, 3.75],
...> [5.0, 2.25]])
{:ok, [0.785, 0.425]}