@kanaries/ml
API Reference/Linear Models

Linear Models

Explore linear regression, logistic regression, regularized regression, and linear classification in JavaScript and TypeScript with @kanaries/ml.

Module overview

The Linear module provides simple, fast, and interpretable supervised learning algorithms for common tabular problems. These models are often the best starting point when you want a strong baseline before moving to trees, SVMs, or ensembles.

This module is a strong fit when:

  • you need transparent coefficients and easy-to-debug predictions
  • training speed and low implementation overhead matter
  • you are solving common regression, regularized regression, or classification tasks

JavaScript implementation

@kanaries/ml provides core linear models in JavaScript and TypeScript so teams can keep prediction logic close to application code. This is especially useful for browser demos, pricing tools, forecasting helpers, and product features where stakeholders care about both the result and the reasoning behind it.

If someone searches for "linear regression in JavaScript" or "logistic regression in TypeScript", this module is the right entry point.

Quick navigation

Detailed module guide

How to choose an algorithm

  1. Use Linear Regression for continuous targets.
  2. Use Ridge Regression, Lasso Regression, or ElasticNet when plain linear regression overfits or coefficients are unstable.
  3. Use Polynomial Regression when a smooth nonlinear relationship is enough.
  4. Use Logistic Regression or RidgeClassifier for classification.

JavaScript deployment notes

  • Normalize numeric inputs when optimization stability matters.
  • Linear models are often ideal when you need predictions to remain explainable to both engineers and stakeholders.
  • Keep them in the application layer when the product benefits from transparent, low-latency inference.