ml_linear_regression

A lightweight Dart package that implements simple linear regression using the least squares method.

Useful for numeric predictions such as price estimation, productivity modeling, trend analysis, and educational performance estimation.


✨ Features

  • Train (fit) with input-output data
  • Predict new values (predict or predictOne)
  • Inspect model equation (slope, intercept)
  • Evaluate performance (score, meanSquaredError)
  • Zero-variance and validation-safe

🚀 Quick Example

final model = LinearRegression();

model.fit([1, 2, 3], [3, 5, 7]); // y ≈ 2x + 1
print(model.predictOne(4));     // ≈ 9
print(model.score([1,2,3], [3,5,7])); // ≈ 1.0