# TranPy
Machine learning tool for power system transient stability analysis with a simple, sklearn-style API.
## Quick Start
```bash
pip install tranpy
```
```python
from tranpy.datasets import load_newengland
from tranpy.models import SVMClassifier
X_train, X_test, y_train, y_test = load_newengland(test_size=0.2, random_state=42)
model = SVMClassifier(kernel='rbf')
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.4f}")
results = model.evaluate(X_test, y_test, verbose=True)
```
### XAI
```python
from tranpy.explainers import SHAPExplainer
# Create explainer
explainer = SHAPExplainer(model, X_train, X_test)
# Generate global explanations
shap_values = explainer.explain_global()
# Visualize
explainer.plot_summary(save_path='shap_summary.png')
# Important features
top_features = explainer.get_top_features(n_features=10)
print(top_features)
``
Check out the [examples/](examples/) directory for Jupyter notebooks:
- `01_load_dataset.ipynb`
- `02_train_models.ipynb`
- `03_explainability.ipynb`
- `04_generate_data.ipynb` - > Requires PowerFactory local installation
Raw data
{
"_id": null,
"home_page": null,
"name": "tranpy-ai",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "power-system, stability-analysis, machine-learning, explainability, transient-stability",
"author": null,
"author_email": "Mahmoud Draz <m.draz@tu-berlin.de>",
"download_url": "https://files.pythonhosted.org/packages/ba/82/78ceb569eeac5896c56e127542f98f1c7db68f9068b962d06463ad491a80/tranpy_ai-0.1.2.tar.gz",
"platform": null,
"description": "# TranPy\n\nMachine learning tool for power system transient stability analysis with a simple, sklearn-style API.\n\n## Quick Start\n\n```bash\npip install tranpy\n```\n\n```python\nfrom tranpy.datasets import load_newengland\nfrom tranpy.models import SVMClassifier\n\nX_train, X_test, y_train, y_test = load_newengland(test_size=0.2, random_state=42)\nmodel = SVMClassifier(kernel='rbf')\nmodel.fit(X_train, y_train)\n\naccuracy = model.score(X_test, y_test)\nprint(f\"Accuracy: {accuracy:.4f}\")\n\nresults = model.evaluate(X_test, y_test, verbose=True)\n```\n\n### XAI \n\n```python\nfrom tranpy.explainers import SHAPExplainer\n\n# Create explainer\nexplainer = SHAPExplainer(model, X_train, X_test)\n\n# Generate global explanations\nshap_values = explainer.explain_global()\n\n# Visualize\nexplainer.plot_summary(save_path='shap_summary.png')\n\n# Important features\ntop_features = explainer.get_top_features(n_features=10)\nprint(top_features)\n``\n\nCheck out the [examples/](examples/) directory for Jupyter notebooks:\n\n- `01_load_dataset.ipynb`\n- `02_train_models.ipynb`\n- `03_explainability.ipynb`\n- `04_generate_data.ipynb` - > Requires PowerFactory local installation\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Power System Transient Stability Analysis with Machine Learning and Explainability",
"version": "0.1.2",
"project_urls": {
"Changelog": "https://github.com/mahmouddraz/tranpy/releases",
"Documentation": "https://mahmouddraz.github.io/tranpy",
"Homepage": "https://github.com/mahmouddraz/tranpy",
"Issues": "https://github.com/mahmouddraz/tranpy/issues",
"Repository": "https://github.com/mahmouddraz/tranpy"
},
"split_keywords": [
"power-system",
" stability-analysis",
" machine-learning",
" explainability",
" transient-stability"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e00134489b7508105fae8967797238e2a7a3d0e9ad93dd3e20339078388536d3",
"md5": "32b85328962366ae06effbc798903f35",
"sha256": "701686162051632c2ad9fe7dfe29ca92ac39537e525ca0cdb094ebb859a5e32f"
},
"downloads": -1,
"filename": "tranpy_ai-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32b85328962366ae06effbc798903f35",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 65772,
"upload_time": "2025-10-14T21:35:30",
"upload_time_iso_8601": "2025-10-14T21:35:30.538707Z",
"url": "https://files.pythonhosted.org/packages/e0/01/34489b7508105fae8967797238e2a7a3d0e9ad93dd3e20339078388536d3/tranpy_ai-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ba8278ceb569eeac5896c56e127542f98f1c7db68f9068b962d06463ad491a80",
"md5": "7b0600d2b01c33b7220ecf1f94751d5c",
"sha256": "8ebcd95b688c82a0d44c1df01c0988aa6907cd6d85f4aeb011467241b880228b"
},
"downloads": -1,
"filename": "tranpy_ai-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "7b0600d2b01c33b7220ecf1f94751d5c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 61972,
"upload_time": "2025-10-14T21:35:31",
"upload_time_iso_8601": "2025-10-14T21:35:31.727741Z",
"url": "https://files.pythonhosted.org/packages/ba/82/78ceb569eeac5896c56e127542f98f1c7db68f9068b962d06463ad491a80/tranpy_ai-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-14 21:35:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mahmouddraz",
"github_project": "tranpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tranpy-ai"
}