Metadata-Version: 2.5
Name: pyegwml
Version: 0.1.0
Summary: Explainable Geographically Weighted Machine Learning with GeoXGBoost, TreeSHAP, and bootstrap stability.
Project-URL: Homepage, https://github.com/moin-t/PyEGWML
Project-URL: Repository, https://github.com/moin-t/PyEGWML
Project-URL: Issues, https://github.com/moin-t/PyEGWML/issues
Author: Moin
License: MIT License
        
        Copyright (c) 2026 Moin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: explainable ai,geographically weighted machine learning,geoxgboost,shap,spatial machine learning,xgboost
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.10
Requires-Dist: geoxgboost==1.1.0
Requires-Dist: joblib>=1.3
Requires-Dist: numpy>=1.26
Requires-Dist: openpyxl>=3.1
Requires-Dist: pandas>=2.1
Requires-Dist: scikit-learn>=1.4
Requires-Dist: scipy>=1.11
Requires-Dist: shap>=0.47
Requires-Dist: xgboost<=3.0.0,>=2.0
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: matplotlib>=3.8; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: plot
Requires-Dist: matplotlib>=3.8; extra == 'plot'
Description-Content-Type: text/markdown

# pyegwml

`pyegwml` is a Python package for Explainable Geographically Weighted Machine Learning. The backend `model="egxgb"`, combines GeoXGBoost, local TreeSHAP explanations, and bootstrap explanation stability.


Repository: <https://github.com/moin-t/PyEGWML>

## Installation


```bash
pip install pyegwml
```

## Quick Start

```python
import numpy as np
import pandas as pd
from pyegwml import EGWML

rng = np.random.default_rng(42)
n = 80

coords = pd.DataFrame({
    "Xcoord": rng.uniform(0, 1, n),
    "Ycoord": rng.uniform(0, 1, n),
})

X = pd.DataFrame({
    "x1": rng.normal(size=n),
    "x2": rng.normal(size=n),
})

y = 2 * X["x1"] - X["x2"] + rng.normal(0, 0.5, n)

model = EGWML(
    n_trees=50,
    bandwidth=30,
    n_bootstrap=10, 
    n_jobs=-1,
)

model.fit(X=X, y=y, coords=coords)
model.to_excel("egwml_results.xlsx")

print(model.performance_)
print(model.feature_summary_)
```

## Main Outputs

After calling `fit`, the estimator exposes:

- `performance_`: GeoXGBoost performance and optional global XGBoost baseline.
- `predictions_`: observed values, predictions, residuals, and bootstrap prediction summaries.
- `shap_single_`: one-run local TreeSHAP values.
- `shap_mean_`: bootstrap mean local SHAP values.
- `shap_sd_`: bootstrap SHAP standard deviations.
- `sign_stability_`: bootstrap sign stability for each location and feature.
- `stability_lower_` and `stability_upper_`: 95 percent bootstrap interval bounds.
- `interval_crosses_zero_`: whether each bootstrap interval crosses zero.
- `feature_summary_`: feature-level explanation and stability summary.
- `location_feature_`: long table of location-feature results.

## Developers

- Moin Tariq, Muhammad Irfan Haider Khan

(sci.mointariq@gmail.com)