Metadata-Version: 2.4
Name: federated-glm
Version: 0.1.0
Summary: A library for federated learning with Generalized Linear Models
Home-page: https://github.com/mhmdamini/federated-glm
Author: Mohammad Amini
Author-email: m.amini@ufl.edu
Project-URL: Bug Reports, https://github.com/mhmdamini/federated-glm/issues
Project-URL: Source, https://github.com/mhmdamini/federated-glm
Project-URL: Documentation, https://github.com/mhmdamini/federated-glm#readme
Keywords: federated-learning,glm,machine-learning,statistics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: statsmodels>=0.13.0
Requires-Dist: scikit-learn>=1.0.0
Requires-Dist: pandas>=1.3.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: sphinx; extra == "dev"
Requires-Dist: sphinx-rtd-theme; extra == "dev"
Provides-Extra: examples
Requires-Dist: matplotlib; extra == "examples"
Requires-Dist: seaborn; extra == "examples"
Requires-Dist: jupyter; extra == "examples"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

````markdown
# Federated GLM

[![PyPI - Version](https://img.shields.io/pypi/v/federated-glm.svg)](https://pypi.org/project/federated-glm/)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python Versions](https://img.shields.io/pypi/pyversions/federated-glm.svg)](https://pypi.org/project/federated-glm/)

**Federated GLM** is a Python package for simulating **federated learning** with **generalized linear models (GLMs)**. It supports Gaussian, Binomial, and Poisson families, and allows flexible experimentation with elastic net regularization, client data partitioning, and convergence diagnostics.

---

## 🔧 Features

- Federated learning framework with `average` or `weighted` aggregation
- Supports **Gaussian**, **Binomial**, and **Poisson** GLM families
- Elastic Net, Lasso, and Ridge regularization (proximal updates)
- Utilities for synthetic data generation and partitioning across clients
- Model evaluation with R², RMSE, accuracy, Poisson deviance, etc.
- Examples for comparing centralized and federated learning
- Simple API and complete test coverage

---

## 📦 Installation

```bash
pip install git+https://github.com/mhmdamini/federated-glm.git
````

To install with development or example dependencies:

```bash
pip install "federated-glm[dev]"
pip install "federated-glm[examples]"
```

---

## 🛠 Quick Start

Here’s a minimal example using Gaussian regression:

```python
from federated_glm import FederatedLearningManager, DataGenerator, ModelEvaluator

# Generate synthetic data
X, y, family = DataGenerator.generate_glm_data("gaussian", n=200, p=3)

# Split train/test
X_train, X_test = X[:150], X[150:]
y_train, y_test = y[:150], y[150:]

# Partition data across clients
client_data = DataGenerator.partition_data(X_train, y_train, n_clients=3)

# Train a federated model
manager = FederatedLearningManager()
manager.fit(client_data, family, n_rounds=10)

# Predict and evaluate
y_pred = manager.predict(X_test, family)
metrics = ModelEvaluator.evaluate(y_test, y_pred, "gaussian")

print("R² Score:", metrics["r2_score"])
print("RMSE:", metrics["rmse"])
```

---

## 📁 Project Structure

```
federated-glm/
├── federated_glm/             # Core package
│   ├── core.py                # Federated GLM base class with proximal optimization
│   ├── federation.py          # Federated learning manager
│   ├── evaluation.py          # Model evaluation metrics
│   ├── utils.py               # Data generation & partitioning utilities
│   └── __init__.py
├── examples/                  # Usage examples
│   └── basic_example.py
├── tests/                     # Unit and integration tests
│   └── test_basic.py
├── requirements.txt
├── setup.py
├── LICENSE
└── README.md
```

---

## 📈 Examples

Run the full demo script:

```bash
python examples/basic_example.py
```

This includes:

* Federated vs centralized performance comparison
* Convergence visualization
* Comparison of regularization strategies (ordinary, lasso, elastic net)

---

## ✅ Supported GLM Families

| Family   | Link Function | Use Case                         |
| -------- | ------------- | -------------------------------- |
| Gaussian | Identity      | Regression on continuous targets |
| Binomial | Logit         | Binary classification            |
| Poisson  | Log           | Count data modeling              |

---

## 🧪 Testing

To run tests:

```bash
pip install "federated-glm[dev]"
pytest tests/
```

---

## 📚 Documentation

Documentation is available in the [GitHub README](https://github.com/mhmdamini/federated-glm#readme).

---

## 📜 License

This project is licensed under the [MIT License](LICENSE).

---

## 👨‍💻 Author

**Mohammad Amini**
Ph.D. Student at University of Florida
[m.amini@ufl.edu](mailto:m.amini@ufl.edu)
[GitHub: @mhmdamini](https://github.com/mhmdamini)

---

## 🙌 Acknowledgements

* Built on [StatsModels](https://www.statsmodels.org/) and [Scikit-learn](https://scikit-learn.org/)
* Inspired by research in federated learning, GLMs, and distributed optimization

---

## 📬 Contributing & Issues

Please open issues or submit pull requests via the [GitHub repository](https://github.com/mhmdamini/federated-glm).

We welcome contributions to:

* Support more GLM families (e.g., Negative Binomial, Gamma)
* Extend to real-world datasets
* Add differential privacy or secure aggregation

---
