Metadata-Version: 2.5
Name: tranpy-ai
Version: 0.2.0.dev0
Summary: Machine learning for power-system transient stability: datasets, models, evaluation and explanation
Project-URL: Homepage, https://github.com/mahmouddraz/tranpy
Project-URL: Repository, https://github.com/mahmouddraz/tranpy
Project-URL: Issues, https://github.com/mahmouddraz/tranpy/issues
Author-email: Mahmoud Draz <m.draz@tu-berlin.de>
License-Expression: MIT
Keywords: explainability,machine-learning,power-system,transient-stability
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.1
Requires-Dist: platformdirs>=4.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: scikit-learn<1.11,>=1.5
Requires-Dist: scipy>=1.11
Provides-Extra: all
Requires-Dist: dalex>=1.7; extra == 'all'
Requires-Dist: lightgbm>=4.0; extra == 'all'
Requires-Dist: lime>=0.2.0.1; extra == 'all'
Requires-Dist: matplotlib>=3.8; extra == 'all'
Requires-Dist: setuptools<85; extra == 'all'
Requires-Dist: shap>=0.45; extra == 'all'
Requires-Dist: skops>=0.10; extra == 'all'
Requires-Dist: tensorflow>=2.16; extra == 'all'
Requires-Dist: xgboost>=2.0; extra == 'all'
Provides-Extra: boosting
Requires-Dist: lightgbm>=4.0; extra == 'boosting'
Requires-Dist: xgboost>=2.0; extra == 'boosting'
Provides-Extra: explain
Requires-Dist: dalex>=1.7; extra == 'explain'
Requires-Dist: lime>=0.2.0.1; extra == 'explain'
Requires-Dist: setuptools<85; extra == 'explain'
Requires-Dist: shap>=0.45; extra == 'explain'
Provides-Extra: neural
Requires-Dist: tensorflow>=2.16; extra == 'neural'
Provides-Extra: persistence
Requires-Dist: skops>=0.10; extra == 'persistence'
Provides-Extra: plot
Requires-Dist: matplotlib>=3.8; extra == 'plot'
Description-Content-Type: text/markdown

# TranPy

<!-- intro-start -->
Machine learning for power-system transient stability.
<!-- intro-end -->

## Installation

```bash
pip install tranpy-ai
```

Optional extras: `tranpy-ai[explain]`, `tranpy-ai[neural]`, `tranpy-ai[boosting]`, `tranpy-ai[plot]`, or `tranpy-ai[all]`.

Requires Python 3.11 or newer.

## Get started

```python
import tranpy
from tranpy_core import evaluate, make_pipeline, train_test_split

data = tranpy.load_new_england()
split = train_test_split(data.labels, test_size=0.2, seed=42)

model = make_pipeline("random_forest", seed=0)
model.fit(data.features[split.train], data.labels[split.train])

scores = evaluate(model, data.features[split.test], data.labels[split.test])
print(scores.accuracy, scores.roc_auc)
```

## Example: early prediction

How soon after a fault can stability be predicted?

```python
import tranpy
from tranpy.early_prediction import run_early_prediction
from tranpy_core.models import make_pipeline

events = tranpy.open_event_shards("ieee_9bus")

results = run_early_prediction(
    events,
    {"random forest": make_pipeline("random_forest", seed=0)},
    reference="fault_start",
    windows_s=(0.05, 0.1, 0.2),
)
print(results[["window_s", "model", "accuracy_mean"]])
```

## Learn more

- [Examples](examples/)
- [Architecture](docs/architecture.md)
- [Data](docs/data.md)
- [Validation](docs/validation.md)

## License

MIT
