API Reference

This page provides the detailed API documentation for the glmpynet package.

LogisticRegression Class

The LogisticRegression class is the main user-facing estimator in the glmpynet library. It is designed to be a fully compatible, drop-in replacement for sklearn.linear_model.LogisticRegression, but is architected to be powered by the high-performance glmnetpp C++ engine.

class glmpynet.logistic_regression.LogisticRegression(penalty: str = 'l2', C: float = 1.0, alpha: float = None, nlambda: int = 100, binding: GlmNetBinding = None)[source]

A scikit-learn compatible estimator for penalized logistic regression.

This class provides a user-friendly hybrid API. By default, it accepts scikit-learn style parameters like C and penalty. It also provides an “escape hatch” for advanced users to pass glmnet-native parameters like alpha and nlambda directly.

Parameters:
  • penalty ({'l1', 'l2'}, default='l2') – Specifies the norm of the penalty.

  • C (float, default=1.0) – Inverse of regularization strength; must be a positive float.

  • alpha (float, optional) – The elastic net mixing parameter, with 0 <= alpha <= 1. If provided, this will override the penalty parameter.

  • nlambda (int, default=100) – The number of lambda values in the regularization path.

__init__(penalty: str = 'l2', C: float = 1.0, alpha: float = None, nlambda: int = 100, binding: GlmNetBinding = None)[source]

Initializes the LogisticRegression model. The constructor is “lean” and only stores parameters. All validation and translation happens in fit.

fit(X, y)[source]

Fit the logistic regression model according to the given training data.

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

predict(X)[source]

Predict class labels for samples in X.

predict_proba(X)[source]

Probability estimates for samples in X.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance