Metadata-Version: 2.4
Name: gpu-glm
Version: 0.1.2
Summary: Regularized GLM models running on a GPU.
Author-email: Greg McMahan <gmcmacran@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/gmcmacran/gpu_glm
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.4.3
Requires-Dist: scipy>=1.17.1
Provides-Extra: gpu
Requires-Dist: cupy>=14.0.1; extra == "gpu"
Provides-Extra: dev
Requires-Dist: numpy>=2.4.3; extra == "dev"
Requires-Dist: scipy>=1.17.1; extra == "dev"
Requires-Dist: scikit-learn>=1.8.0; extra == "dev"
Requires-Dist: pytest>=9.0.2; extra == "dev"
Requires-Dist: ruff>=0.15.1; extra == "dev"
Requires-Dist: pre-commit>=4.5.1; extra == "dev"
Requires-Dist: mkdocs>=1.6.1; extra == "dev"
Requires-Dist: mkdocs-material>=9.7.1; extra == "dev"
Requires-Dist: mkdocstrings[python]>=1.0.3; extra == "dev"
Dynamic: license-file

# gpu_glm

A lightweight Python implementation of Generalized Linear Models (GLMs) that runs on a GPU. 

This package provides:

- Gaussian, Bernoulli, Poisson, Gamma, and Inverse Gaussian models.
- Multiple link functions (identity, log, inverse, logit, probit, etc.)
- A Cupy-based implementation that falls back to Numpy.
- A sci-kit learn interface.
- L2 regularization.

---

## Installation
To use the GPU, cupy must be installed with a GPU dependancies already working. If cupy is unavailable, numpy is used.  

```bash
pip install gpu-glm
```

A conda package to handle GPU dependancies is under development.


## Quick Example

Below fits a linear regression model.

```python
import numpy as np
from gpu_glm import gaussian_glm
from sklearn.metrics import root_mean_squared_error

# Simulated data
X = np.column_stack([np.random.randn(100), np.ones(100)])
y = 2 * X[:, 0] + 3 +  np.random.randn(100)

# Fit model
model = gaussian_glm()
model.fit(X, y)
print(f"coefficients: {model.coef()}")

y_hat = model.predict(X)
rmse = root_mean_squared_error(y, y_hat)
print(f"RMSE: {np.round(rmse, 3)}")
```
