This LinearRegression type summarized the most common fitting procedures.
// e.g. days since experiment start
let xData = vector [|1. .. 100.|]
// e.g. plant size in cm
let yData = vector [|4.;7.;8.;9.;7.;11.; ...|]
// Estimate the intercept and slope of a line, that fits the data.
let coefficientsSimpleLinear =
LinearRegression.fit(xData,yData,FittingMethod=Fitting.Method.SimpleLinear,Constraint=Fitting.Constraint.RegressionThroughOrigin)
// Predict the size on day 10.5
LinearRegression.predict(coefficientsSimpleLinear) 10.5
Constructor | Description |
|
|
Static member | Description |
Full Usage:
LinearRegression.fit (xData, yData, ?FittingMethod)
Parameters:
matrix
-
matrix of x vectors
yData : Vector<float>
-
vector of y values
?FittingMethod : Method
-
Multivariate regression currently just supports Fitting.SimpleLinear (straight line).
Returns: Coefficients
Linear regression coefficients for multivariate regression.
|
Default is simple linear regression fitting without constraints.
Example
|
Full Usage:
LinearRegression.fit (xData, yData, ?FittingMethod, ?Constraint, ?Weighting)
Parameters:
vector
-
vector of x values
yData : Vector<float>
-
vector of y values
?FittingMethod : Method
-
Either Fitting.SimpleLinear (straight line), Fitting.Polynomial (polynomial), or Fitting.Robust (outlier insensitive straight line).
?Constraint : Constraint<float * float>
-
Either Fitting.Unconstrained, Fitting.RegressionThroughOrigin, or Fitting.RegressionThroughXY (x,y) with x,y beeing coordinates that the line must pass.
?Weighting : vector
-
If a pointwise weight should be attached, a weight vector can be given, that is in the same order as x/y values.
Returns: Coefficients
Linear regression coefficients.
|
Default is simple linear regression fitting without constraints.
Example
|
Full Usage:
LinearRegression.predict coeff xValue
Parameters:
Coefficients
-
Linear regression coefficients (e.g. from LinearRegression.fit())
xValue : float
Returns: float
Prediction function that takes an x value and predicts its corresponding y value.
|
Example
|
Full Usage:
LinearRegression.predictMultivariate coeff xVector
Parameters:
Coefficients
-
Multivariate linear regression coefficients (e.g. from LinearRegression.fit())
xVector : vector
Returns: float
Prediction function that takes an x vector and predicts its corresponding y value.
|
Example
|