O'Reilly logo
  • black zwei thinks this is interesting:

let input = [|1,1.;2,2.;3,2.25;4,4.75;5,5.|] let x = input |> Array.map (fun (x,y) -> float x) let y = input |> Array.map (fun (x,y) -> y) let regression = SimpleLinearRegression() let sse = regression.Regress(x,y) let intercept = regression.Intercept let slope = regression.Slope let mse = sse/float x.Length let rmse = sqrt mse let r2 = regression.CoefficientOfDetermination(x,y)

From

Cover of Mastering .NET Machine Learning

Note

Code is out of date in new version Accord.NET.
use below:

let regression = OrdinaryLeastSquares().Learn(x, y)
let intercept = regression.Intercept
let slope = regression.Slope

// sum of square error
let loss = new SquareLoss(y)
// mean if mean then mse(default)
//loss.Mean <- false
// first root then mean in source code.
loss.Root <- false
let actual = regression.Transform(x)
let sse = loss.Loss(actual)

let r2 = regression.CoefficientOfDetermination(x,y)