MachineLearning/linear_regression library

📈 Linear Regression (Ordinary Least Squares)

Simple linear regression (ordinary least squares) for a single predictor or multiple predictors implemented with a numerically stable formula for the slope(s) and intercept. Returns fitted coefficients in the shape [intercept, b1, b2, ...] and provides a small predictor helper.

Contract:

  • Input: feature matrix X as List<List
  • Output: List

Time Complexity: O(n*m^2) (naive normal-equation with small m) Space Complexity: O(m^2)

Classes

LinearRegressionModel
Thin object wrapper around the functional API to provide a uniform fit/predict interface used across the ML modules.

Functions

linearRegressionFit(List<List<double>> X, List<double> y) → List<double>
linearRegressionPredict(List<double> coeffs, List<double> features) → double