Skip to main content

Geospatial eXplanation Conformal Prediction (GeoXCP)

Project description

GeoXCP

Geospatial eXplanation Conformal Prediction (GeoXCP) is a powerful framework to measure uncertainty of spatial explanations.

Usage

from GeoConformalizedExplainer import GeoConformalizedExplainer
from xgboost import XGBRegressor
from sklearn.model_selection import train_test_split
import pandas as pd

data = pd.read_csv('...')
X_geo = data[['X1', 'X2', 'X3', 'X4', 'X5']]
y = data['y']
loc = data[['lon', 'lat']]

X_train, X_temp, y_train, y_temp, _, loc_temp = train_test_split(X_geo, y, loc, train_size=0.8, random_state=42)
X_calib, X_test, y_calib, y_test, loc_calib, loc_test = train_test_split(X_geo, y, loc_temp, train_size=0.5, random_state=42)
feature_names = X_geo.columns

# Fit a XGBoost Regressor model
model = XGBRegressor().fit(X_train, y_train)

# Initialize a GeoXCP Explainer
explainer = GeoConformalizedExplainer(prediction_f=model.predict,
                                      x_train=X_train,
                                      x_calib=X_calib,
                                      coord_calib=loc_calib.values,
                                      miscoverage_level=0.1,
                                      band_width=0.3,
                                      feature_names=feature_names)

# Explain the data with uncertainty
results = explainer.uncertainty_aware_explain(x_test=X_test, coord_test=loc_test)

# Make an accuracy summary
results.accuracy_summary()

# Convert the results into GeoPandas GeoDataFrame format
pred_results = results.result_geo

# Plot the shap values with uncertainty for certain location
results.plot_shap_values_with_uncertainty(i=20)

# Plot the spatial distribution of uncertainty
results.plot_geo_uncertainty()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geoxcp-1.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file geoxcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: geoxcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for geoxcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2937902e834c893d744ed9fe094b6c19476dfc22ab3f396cbb1afa6daa24b62
MD5 35cb017886eddc739bb0073b7f4a3b09
BLAKE2b-256 ab79fa30de1b3ef822d061a17e2403fd5e49f3366df70d96a6ef2b4b134d4525

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page