LinearRegression
Ordinary Least Squares linear regression — analytical Gram/Cholesky solver. / Régression linéaire par moindres carrés ordinaires — solveur analytique Gram/Cholesky.
⚡ Rust-native
✓ sklearn parity
Quick start — Python
import seraplot as sp, numpy as np
X = np.random.randn(500, 4)
y = X @ [2, -1, 0.5, 1.5] + np.random.randn(500) * 0.3
model = sp.LinearRegression()
model.fit(X, y)
print(model.coef_, model.intercept_, model.score(X, y))
EN — Drop-in replacement:
FR — Remplacement direct : même API que sklearn, changez l'import.
sp.LinearRegression has the same API as sklearn.FR — Remplacement direct : même API que sklearn, changez l'import.
API Reference
JSON function name
ml_linear_regression — aliases: linear_regression, linreg
Python class
sp.LinearRegression(fit_intercept=true)
Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fit_intercept | bool | true | Fit an intercept term. |
Returns
JSON with predictions, coef, intercept.
Algorithm
$$\hat{\beta} = (X^T X)^{-1} X^T y$$
Example
import seraplot as sp, numpy as np
X = np.random.randn(500, 4)
y = X @ [2, -1, 0.5, 1.5] + np.random.randn(500) * 0.3
model = sp.LinearRegression()
model.fit(X, y)
print(model.coef_, model.intercept_, model.score(X, y))
Référence API
Nom de fonction JSON
ml_linear_regression — alias : linear_regression, linreg
Classe Python
sp.LinearRegression(fit_intercept=true)
Paramètres du constructeur
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
fit_intercept | bool | true | Ajuster un terme d'intercept. |
Retourne
JSON avec predictions, coef, intercept.
Algorithme
$$\hat{\beta} = (X^T X)^{-1} X^T y$$
Exemple
import seraplot as sp, numpy as np
X = np.random.randn(500, 4)
y = X @ [2, -1, 0.5, 1.5] + np.random.randn(500) * 0.3
model = sp.LinearRegression()
model.fit(X, y)
print(model.coef_, model.intercept_, model.score(X, y))