LogisticRegression
Logistic regression — L2-regularised binary/multiclass via Newton-CG. / Régression logistique — binaire/multi-classe L2 via Newton-CG.
⚡ Rust-native
✓ sklearn parity
Quick start — Python
import seraplot as sp, numpy as np
X = np.random.randn(400, 4)
y = (X[:, 0] + X[:, 1] > 0).astype(int)
model = sp.LogisticRegression(C=1.0)
model.fit(X, y)
print(f"Accuracy: {model.score(X, y):.3f}")
EN — Drop-in replacement:
FR — Remplacement direct : même API que sklearn, changez l'import.
sp.LogisticRegression has the same API as sklearn.FR — Remplacement direct : même API que sklearn, changez l'import.
API Reference
JSON function name
ml_logistic_regression — aliases: logistic_regression, logistic
Python class
sp.LogisticRegression(C=1.0, max_iter=100, tol=1e-4, fit_intercept=true)
Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
C | float | 1.0 | Inverse regularisation strength (larger = less reg). |
max_iter | int | 100 | Maximum iterations. |
tol | float | 1e-4 | Convergence tolerance. |
fit_intercept | bool | true | Fit an intercept term. |
Returns
JSON with predictions, coef, intercept, classes.
Algorithm
$$P(y=1|x) = \sigma(x^T\beta + b), \quad \sigma(z) = \frac{1}{1+e^{-z}}$$
Example
import seraplot as sp, numpy as np
X = np.random.randn(400, 4)
y = (X[:, 0] + X[:, 1] > 0).astype(int)
model = sp.LogisticRegression(C=1.0)
model.fit(X, y)
print(f"Accuracy: {model.score(X, y):.3f}")
Référence API
Nom de fonction JSON
ml_logistic_regression — alias : logistic_regression, logistic
Classe Python
sp.LogisticRegression(C=1.0, max_iter=100, tol=1e-4, fit_intercept=true)
Paramètres du constructeur
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
C | float | 1.0 | Force de régularisation inverse (plus grand = moins de régul.). |
max_iter | int | 100 | Nombre maximum d'itérations. |
tol | float | 1e-4 | Tolérance de convergence. |
fit_intercept | bool | true | Ajuster un terme d'intercept. |
Retourne
JSON avec predictions, coef, intercept, classes.
Algorithme
$$P(y=1|x) = \sigma(x^T\beta + b), \quad \sigma(z) = \frac{1}{1+e^{-z}}$$
Exemple
import seraplot as sp, numpy as np
X = np.random.randn(400, 4)
y = (X[:, 0] + X[:, 1] > 0).astype(int)
model = sp.LogisticRegression(C=1.0)
model.fit(X, y)
print(f"Précision : {model.score(X, y):.3f}")