Skip to main content

A scikit-learn compatible wrapper for glmnet-based logistic regression.

Project description

glmpynet

CircleCI ReadTheDocs Codecov

glmnet-based Logistic Regression for Scikit-Learn

glmpynet is a Python package that provides a scikit-learn compatible interface to the high-performance glmnet library, focusing on penalized logistic regression for binary classification.

This project aims to bridge the gap between the raw computational speed of the original Fortran/C++ glmnet code and the ease-of-use of the Python data science ecosystem. It provides a single, focused class that acts as a drop-in replacement for sklearn.linear_model.LogisticRegression for users who need the power of elastic-net regularization for binary classification.

Key Features

  • High Performance: Leverages the highly optimized, battle-tested glmnet Fortran backend for fitting models, making it suitable for large datasets.

  • Scikit-learn Compatible: Implements the standard fit, predict, and predict_proba API, allowing it to be seamlessly integrated into sklearn pipelines, GridSearchCV, and other tools.

  • Full Regularization Suite: Supports L1 (Lasso), L2 (Ridge), and Elastic-Net regularization for robust feature selection and prevention of overfitting.

Installation

Once released, you will be able to install glmpynet via pip:

pip install glmpynet

Quick Start

Using glmpynet is designed to be as simple as using any other scikit-learn estimator.

import numpy as np
from glmpynet import LogisticNet
from sklearn.model\_selection import train\_test\_split
from sklearn.metrics import accuracy\_score

1. Generate synthetic data

X, y = np.random.rand(100, 10), np.random.randint(0, 2, 100)
X\_train, X\_test, y\_train, y\_test = train\_test\_split(X, y)

2. Instantiate and fit the model

# alpha=1 -\> Lasso, alpha=0 -\> Ridge, 0 \< alpha \< 1 -\> Elastic-Net

model = LogisticNet(alpha=0.5)
model.fit(X\_train, y\_train)

3. Make predictions

y\_pred = model.predict(X\_test)

4. Evaluate the model

accuracy = accuracy\_score(y\_test, y\_pred)
print(f"Model Accuracy: {accuracy:.2f}")

Project Status

This project is currently in the planning and development phase. The goal is to provide a simple, robust, and well-tested wrapper for the core binary classification functionality of glmnet.

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines on how to report bugs, suggest features, or submit pull requests.

License

This project is distributed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glmpynet-0.4.9.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glmpynet-0.4.9-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file glmpynet-0.4.9.tar.gz.

File metadata

  • Download URL: glmpynet-0.4.9.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for glmpynet-0.4.9.tar.gz
Algorithm Hash digest
SHA256 d53631a2b63e6e66a5c83ed0f2564c17db434150ef2b3f0fd375e5f090dfc3cf
MD5 ead74dba3b44b3e4b7deb89e6b8a87e0
BLAKE2b-256 64f9b8dcf73f4ab21d50cd94799f13e7dd1178cda9f4bd5243e5cae618118028

See more details on using hashes here.

File details

Details for the file glmpynet-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: glmpynet-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for glmpynet-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4da4db7427a01689ee7f27c0c09b3048091b9f8be6936340a45cb807f0e4f4b5
MD5 1fe09904c4b4083fa1e4a628b09cfdab
BLAKE2b-256 b9c479b750fe8706bf8a43985287b98ef5b92a5ce0d6fe025f7a2dea3613cb95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page