Ridge
Ridge regression — L2-penalised OLS with Cholesky solver. / Régression Ridge — OLS pénalisée L2 avec solveur Cholesky.
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = X @ np.array([1, -2, 0.5, 1.5, -0.8]) + np.random.randn(300)
reg = sp.Ridge(alpha=0.5)
reg.fit(X, y)
print(f"R²: {reg.score(X, y):.4f}")
sp.Ridge has the same API as sklearn.FR — Remplacement direct : même API que sklearn, changez l'import.
API Reference
ml_ridge — aliases: ridge, ridge_regression
sp.Ridge(alpha=1.0, fit_intercept=true)
| Parameter | Type | Default | Description |
|---|---|---|---|
alpha | float | 1.0 | L2 regularisation strength. |
fit_intercept | bool | true | Fit an intercept term. |
JSON with predictions, coef, intercept.
$$\hat{\beta} = (X^TX + \alpha I)^{-1}X^Ty$$
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = X @ np.array([1, -2, 0.5, 1.5, -0.8]) + np.random.randn(300)
reg = sp.Ridge(alpha=0.5)
reg.fit(X, y)
print(f"R²: {reg.score(X, y):.4f}")
Référence API
ml_ridge — alias : ridge, ridge_regression
sp.Ridge(alpha=1.0, fit_intercept=true)
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
alpha | float | 1.0 | Force de régularisation L2. |
fit_intercept | bool | true | Ajuster un terme d'intercept. |
JSON avec predictions, coef, intercept.
$$\hat{\beta} = (X^TX + \alpha I)^{-1}X^Ty$$
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = X @ [1, -2, 0.5, 1.5, -0.8] + np.random.randn(300)
reg = sp.Ridge(alpha=0.5)
reg.fit(X, y)
print(f"R² : {reg.score(X, y):.4f}")
RidgeClassifier
Ridge classifier — one-vs-rest Ridge regression mapped to class labels. / Classificateur Ridge — régression Ridge one-vs-rest mappée en labels.
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = (X[:, 0] - X[:, 2] > 0).astype(int)
clf = sp.RidgeClassifier(alpha=1.0)
clf.fit(X, y)
print(f"Accuracy: {clf.score(X, y):.3f}")
sp.RidgeClassifier has the same API as sklearn.FR — Remplacement direct : même API que sklearn, changez l'import.
API Reference
ml_ridge_classifier — aliases: ridge_classifier, ridge_cls
sp.RidgeClassifier(alpha=1.0)
| Parameter | Type | Default | Description |
|---|---|---|---|
alpha | float | 1.0 | L2 regularisation strength. |
JSON with predictions.
$$\hat{y} = \text{sign}(X\hat{\beta}), \quad \hat{\beta} = (X^TX + \alpha I)^{-1}X^TY$$
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = (X[:, 0] - X[:, 2] > 0).astype(int)
clf = sp.RidgeClassifier(alpha=1.0)
clf.fit(X, y)
print(f"Accuracy: {clf.score(X, y):.3f}")
Référence API
ml_ridge_classifier — alias : ridge_classifier, ridge_cls
sp.RidgeClassifier(alpha=1.0)
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
alpha | float | 1.0 | Force de régularisation L2. |
JSON avec predictions.
$$\hat{y} = \text{sign}(X\hat{\beta}), \quad \hat{\beta} = (X^TX + \alpha I)^{-1}X^TY$$
import seraplot as sp, numpy as np
X = np.random.randn(300, 5)
y = (X[:, 0] - X[:, 2] > 0).astype(int)
clf = sp.RidgeClassifier(alpha=1.0)
clf.fit(X, y)
print(f"Précision : {clf.score(X, y):.3f}")