---
title: "Linear Models in JavaScript with @kanaries/ml"
description: "Explore linear regression, logistic regression, regularized regression, and linear classification in JavaScript and TypeScript with @kanaries/ml."
canonical_url: "https://ml.kanaries.net/docs/apis/linear"
markdown_url: "https://ml.kanaries.net/docs/apis/linear/index.html.md"
---
# Linear Models in JavaScript

## 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

- [Linear Regression](/docs/apis/linear/linearRegression.md): numeric prediction with interpretable coefficients
- [Polynomial Regression](/docs/apis/linear/polynomialRegression.md): curve fitting through polynomial feature expansion
- [Ridge Regression](/docs/apis/linear/ridgeRegression.md): L2-regularized numeric prediction
- [Lasso Regression](/docs/apis/linear/lassoRegression.md): L1-regularized numeric prediction with sparse coefficients
- [Ridge](ridge): sklearn-style alias for RidgeRegression
- [Lasso](lasso): sklearn-style alias for LassoRegression
- [ElasticNet](/docs/apis/linear/elasticNet.md): combined L1 and L2 regularized regression
- [RidgeClassifier](/docs/apis/linear/ridgeClassifier.md): one-vs-rest L2-regularized linear classification
- [Logistic Regression](/docs/apis/linear/logisticRegression.md): binary classification with probability-oriented outputs
- [Robust Regression](/docs/apis/linear/robustRegressors.md): Huber, RANSAC, Theil-Sen, and conditional quantiles
- [Bayesian Regressors](/docs/apis/linear/bayesianRegressors.md): posterior uncertainty and automatic relevance determination
- [Generalized Linear Models](/docs/apis/linear/generalizedLinearModels.md): Poisson, Gamma, and Tweedie targets

## Detailed module guide

### How to choose an algorithm

1. Use [Linear Regression](/docs/apis/linear/linearRegression.md) for continuous targets.
2. Use [Ridge Regression](/docs/apis/linear/ridgeRegression.md), [Lasso Regression](/docs/apis/linear/lassoRegression.md), or [ElasticNet](/docs/apis/linear/elasticNet.md) when plain linear regression overfits or coefficients are unstable.
3. Use [Polynomial Regression](/docs/apis/linear/polynomialRegression.md) when a smooth nonlinear relationship is enough.
4. Use [Logistic Regression](/docs/apis/linear/logisticRegression.md) or [RidgeClassifier](/docs/apis/linear/ridgeClassifier.md) 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.
