v2026.5.2
All Bundles

LinearRegression

Simple linear regression using least squares. Fits y = X * coefficients via the normal equation.

Operations

Fit

Fits the model to training data using least squares.

method : public : Fit(X:Float[,], y:Float[,]) ~ Bool

Parameters

NameTypeDescription
XFloatfeature matrix (rows=samples, cols=features)
yFloattarget matrix (rows=samples, cols=1)

Return

TypeDescription
Booltrue if fitting succeeded

GetCoefficients

Gets the computed coefficients.

method : public : GetCoefficients() ~ Float[]

Return

TypeDescription
Floatcoefficient array, or Nil if not fitted

GetRSquared

Gets the R-squared goodness of fit.

method : public : GetRSquared() ~ Float

Return

TypeDescription
FloatR-squared value

IsFitted

Whether the model has been fitted.

method : public : IsFitted() ~ Bool

Return

TypeDescription
Booltrue if fitted

New

Constructor

New()

Predict

Predicts target values for new input data.

method : public : Predict(X:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
XFloatfeature matrix

Return

TypeDescription
Floatprediction matrix, or Nil if not fitted