glm
LogisticFit
Result of a logistic regression fit.
Attributes ---------- coef Estimated coefficients, including the intercept in position 0 when one was requested. se Asymptotic standard errors from the inverse observed information. loglik Maximized log-likelihood. n_obs, n_events Sample size and number of positive outcomes. Reported together because the second, not the first, governs how much a rare-event model can actually learn. converged, n_iter IRLS convergence status. separation_warning Set when the fitted probabilities are numerically 0 or 1 for every observation in some region, which indicates (quasi-)complete separation. The coefficients are then not finite in the limit and the standard errors are meaningless.
king_zeng_correction
Apply the King & Zeng (2001) rare-event bias correction to a fit.
The correction subtracts an estimate of the O(1/n) bias of the ML estimator:
``bias = (X' W X)^-1 X' W xi``, with ``xi_i = 0.5 * Q_ii * ((1 + w1) p_i - w1)``
where ``Q = X (X' W X)^-1 X'`` and ``w1 = 1`` in the no-prior-correction case used here.
Returns the corrected coefficient vector. The reduction in bias is small in absolute terms but concentrated in the intercept, which is exactly the parameter that sets the level of the predicted probabilities -- so it moves calibration, not discrimination.
Citation: King, G., & Zeng, L. (2001). Logistic regression in rare events data. *Political Analysis*, 9(2), 137-163. Verified against the journal record and the authors' copy of the article.
logistic_irls
Fit a logistic regression by IRLS (Fisher scoring).
Parameters ---------- x Design matrix of shape ``(n_obs, n_pred)``, without an intercept column unless ``add_intercept`` is False. y Binary outcome, coded 0/1. add_intercept Prepend a column of ones. ridge Optional L2 penalty on the non-intercept coefficients. A small ridge keeps the algorithm finite under separation; when it is non-zero the standard errors are conditional on the penalty and should not be interpreted as unpenalized asymptotic errors. max_iter, tol Convergence controls on the change in the coefficient vector.
predict_proba
Predicted probabilities for a fitted logistic model.