Skip to main content

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

Project description

glmpynet

CircleCI ReadTheDocs Codecov

Logistic Regression using glmnet for Scikit-Learn

glmpynet is a Python package that provides a scikit-learn-compatible LogisticRegression API powered by the high-performance glmnetpp C++ library.

This project bridges the computational speed of glmnetpp with the ease-of-use of the Python data science ecosystem, acting as a drop-in replacement for sklearn.linear_model.LogisticRegression for regularized logistic regression.

Key Features

  • High Performance: Designed to leverage the optimized glmnetpp C++ backend for fitting models, suitable for large datasets. (Note: Currently uses a mock backend for API development).
  • Fully Scikit-learn Compatible: Implements the full estimator API, including fit, predict, and predict_proba, enabling seamless integration with sklearn tools like Pipeline and GridSearchCV.
  • User-Friendly Hybrid API: Accepts both standard Scikit-learn parameters (e.g., C, penalty) for ease of use and glmnet-native parameters (e.g., alpha, nlambda) for advanced control.
  • Robust Development: Built with Bazel and Conda for reproducible builds, with a comprehensive test suite to ensure reliability.

Installation

Once released, install glmpynet via pip:

pip install glmpynet

Quick Start

Using glmpynet is as simple as any Scikit-learn estimator.

from glmpynet.logistic_regression import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_classification
from sklearn.metrics import accuracy_score

# 1. Generate synthetic data
X, y = make_classification(n_samples=1000, n_features=50, n_informative=10, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 2. Instantiate and fit the model using familiar sklearn parameters
model = LogisticRegression(penalty='l1', C=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

The Python API for glmpynet.LogisticRegression is now complete and fully tested against a mock backend. The next major phase of development is to implement the real C++ binding that connects this API to the glmnetpp engine.

License

This project is distributed under the GNU General Public License version 2.

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.5.8.tar.gz (23.9 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.5.8-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for glmpynet-0.5.8.tar.gz
Algorithm Hash digest
SHA256 e5f48e6f99c704e4fd1bf4b2b92303659b981fe5d6576af940f87c6044142315
MD5 7e3c4e1a8f9d6148a14ab1f7e2eed71d
BLAKE2b-256 7bca04fc1c1c7c21af248a93a172dcf78adb7845d9df22f17739c11df44fe62f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glmpynet-0.5.8-py3-none-any.whl
  • Upload date:
  • Size: 22.0 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.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 557372d2788c9d919a1dfdb828d1b3a939511384bfcb84e165107b2992f5bb28
MD5 94d4743b07bf6df7b3f690eee75c8f87
BLAKE2b-256 79ea0a3be4d704e8a456afb111a649ac19a6f1def8e631f26edb152d41422f84

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