LogisticRegression
LogisticRegression(
alpha=0.0,
l1_ratio=0.0,
fit_intercept=True,
max_iterations=1000,
tolerance=1e-08,
l1_smoothing=1e-06,
)Binary logistic regression estimated by maximum likelihood.
The model minimizes the negative Bernoulli log-likelihood. For regularized fits, the optimizer switches to Frank-Wolfe over an exact L1 or L2 ball. For unregularized fits, the class exposes classical inverse-information covariance estimates and robust QMLE sandwich covariance estimates.
Attributes
| Name | Type | Description |
|---|---|---|
| coef_ | ndarray of shape (n_features,) | Estimated slope coefficients. |
| intercept_ | float | Estimated intercept. Equals 0.0 when fit_intercept=False. |
| params_ | ndarray of shape (n_params,) | Full parameter vector, including the intercept when present. |
| std_errors_ | ndarray or None | Classical standard errors for params_. |
| robust_std_errors_ | ndarray or None | Robust QMLE standard errors for params_. |
Methods
| Name | Description |
|---|---|
| confidence_intervals | Return coefficient confidence intervals. |
| fit | Fit the logistic regression model. |
| predict | Predict binary class labels using a 0.5 threshold. |
| predict_proba | Return class probabilities for the binary response. |
| score | Return mean classification accuracy on the provided sample. |
| summary | Return [coef, se, ci_lb, ci_ub] for each fitted parameter. |
confidence_intervals
LogisticRegression.confidence_intervals(alpha=0.05, covariance_type='nonrobust')Return coefficient confidence intervals.
fit
LogisticRegression.fit(X, y)Fit the logistic regression model.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| X | ndarray of shape (n_samples, n_features) | Feature matrix. | required |
| y | ndarray of shape (n_samples,) | Binary response encoded as 0 or 1. |
required |
Returns
| Name | Type | Description |
|---|---|---|
| LogisticRegression | The fitted estimator. |
predict
LogisticRegression.predict(X)Predict binary class labels using a 0.5 threshold.
predict_proba
LogisticRegression.predict_proba(X)Return class probabilities for the binary response.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| X | ndarray of shape (n_samples, n_features) | Feature matrix. | required |
Returns
| Name | Type | Description |
|---|---|---|
| ndarray of shape (n_samples, 2) | Column-stacked probabilities for classes 0 and 1. |
score
LogisticRegression.score(X, y)Return mean classification accuracy on the provided sample.
summary
LogisticRegression.summary(alpha=0.05, covariance_type='nonrobust')Return [coef, se, ci_lb, ci_ub] for each fitted parameter.