Linear SVR
Learn what Linear SVR does, when to use it, and how to run LinearSVR in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
Algorithm overview
Linear support vector regression trained with Pegasos-style stochastic subgradient descent on the epsilon-insensitive loss.
LinearSVR performs margin-based linear regression with robustness to moderate outliers in target values.
This algorithm is especially useful when:
- You need regression in high-dimensional spaces with linear assumptions.
- Outlier sensitivity from ordinary least squares is causing instability.
- You want a fast margin-based baseline in Node.js services.
JavaScript implementation
@kanaries/ml provides Linear SVR in JavaScript for regression tasks where a linear support-vector objective is preferable to plain least squares. This can be useful in Node.js services and TypeScript applications that need linear-style regression with a margin-based loss and straightforward inference.
It is especially attractive when the rest of the product pipeline is already in JS and you want to keep feature generation and prediction together.
Quick start
LinearSVR in Python vs JavaScript / TypeScript
If you searched for "LinearSVR in JavaScript" or "LinearSVR in TypeScript", this section maps the familiar scikit-learn call to the equivalent @kanaries/ml usage for browser and Node.js runtimes.
from sklearn.svm import LinearSVR
X = [[0], [1], [2], [3]]
y = [1.0, 2.1, 2.9, 4.2]
reg = LinearSVR(C=1.0, epsilon=0.0, random_state=0)
reg.fit(X, y)
pred = reg.predict([[1.5], [2.5]])import { SVM } from '@kanaries/ml';
const X = [[0], [1], [2], [3]];
const y = [1.0, 2.1, 2.9, 4.2];
const reg = new SVM.LinearSVR({ C: 1, epsilon: 0, maxIter: 1000, randomState: 0 });
reg.fit(X, y);
const pred = reg.predict([[1.5], [2.5]]);Quick JavaScript example
import { SVM } from '@kanaries/ml';
const X = [[0], [1], [2], [3]];
const y = [1.0, 2.1, 2.9, 4.2];
const reg = new SVM.LinearSVR({ C: 1, epsilon: 0, maxIter: 1000, randomState: 0 });
reg.fit(X, y);
const pred = reg.predict([[1.5], [2.5]]);Detailed API reference
interface LinearSVRProps {
epsilon?: number;
C?: number;
maxIter?: number;
/** @deprecated ignored — Pegasos uses the schedule eta_t = 1/(lambda*t) */
learningRate?: number;
tol?: number;
randomState?: number;
}
constructor(props: LinearSVRProps = {})Parameters
epsilon(number, default0): width of the insensitive tube around the regression lineC(number, default1): regularization strength, matching sklearn'sCsemantics (internallylambda = 1/(n*C))maxIter(number, default1000): maximum number of training epochs (full passes over the data)tol(number, default1e-4): stopping tolerance — training stops early when the relative improvement of the objective between epochs falls below this valuerandomState(number, optional): seed for the per-epoch shuffling, for reproducible traininglearningRate(deprecated, ignored): the Pegasos optimizer uses the fixed step-size scheduleeta_t = 1/(lambda*t), so this option has no effect
Implementation workflow
- Prepare standardized numeric features and choose epsilon margin.
- Fit LinearSVR and measure MAE/RMSE on holdout data.
- Tune
Cand epsilon for error tolerance versus fit quality.
JavaScript deployment notes
- Use Linear SVR when you want a linear regressor with support-vector-style robustness around small errors.
- Standardize features before training because optimization is sensitive to scale.
- Benchmark it against ordinary linear regression to confirm the margin-based objective improves real error metrics.
Linear SVC
Learn what Linear SVC does, when to use it, and how to run LinearSVC in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
Naive Bayes
Explore Gaussian, Multinomial, Complement, Bernoulli, and Categorical Naive Bayes in JavaScript and TypeScript with @kanaries/ml.