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
- Linear Regression: numeric prediction with interpretable coefficients
- Polynomial Regression: curve fitting through polynomial feature expansion
- Ridge Regression: L2-regularized numeric prediction
- Lasso Regression: L1-regularized numeric prediction with sparse coefficients
- Ridge: sklearn-style alias for RidgeRegression
- Lasso: sklearn-style alias for LassoRegression
- ElasticNet: combined L1 and L2 regularized regression
- RidgeClassifier: one-vs-rest L2-regularized linear classification
- Logistic Regression: binary classification with probability-oriented outputs
Detailed module guide
How to choose an algorithm
- Use Linear Regression for continuous targets.
- Use Ridge Regression, Lasso Regression, or ElasticNet when plain linear regression overfits or coefficients are unstable.
- Use Polynomial Regression when a smooth nonlinear relationship is enough.
- 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.
k-means++ Initialization
Learn what k-means++ Initialization does, when to use it, and how to run kmeansPlusPlus in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
Linear Regression
Learn what Linear Regression does, when to use it, and how to run LinearRegression in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.