Skip to content

Vezarachan/GeoConformalPrediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT Python PyPI

GeoConformal Prediction (GeoCP)

Purpose and Goals

A powerful, model-agnostic tool to measure spatially varying uncertainty of machine learning models. GeoConfromal is an extension of Conformal prediction.

GeoConformal, in theory, supports any machine learning model with spatial (e.g., coordinates) and aspatial (e.g., area of the living) features as the input.

Usage

Regression & Interpolation

from GeoConformalPrediction import GeoConformalRegressor
from xgboost import XGBRegressor
from sklearn.model_selection import train_test_split

X_train, X_temp, y_train, y_temp, loc_train, loc_temp = train_test_split(X, 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_temp, y_temp, loc_temp, train_size=0.5, random_state=42)

model = XGBRegressor(n_estimators=500, max_depth=3, min_child_weight=1.0, colsample_bytree=1.0).fit(X_train.values, y_train.values)

geocp_regressoer = GeoConformalRegressor(predict_f=model.predict, x_calib=X_calib.values, y_calib=y_calib.values, coord_calib=loc_calib.values, bandwidth=0.15, miscoverage_level=0.1)

results = geocp_regressoer.geo_conformalize(X_test.values, y_test.values, loc_test.values)

Classification

from GeoConformalPrediction import GeoConformalClassifier
from xgboost import XGBClassifier
from sklearn.model_selection import train_test_split

X_train, X_temp, y_train, y_temp, loc_train, loc_temp = train_test_split(X, 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_temp, y_temp, loc_temp, train_size=0.5, random_state=42)

model = XGBClassifier(n_estimators=100, max_depth=2, min_child_weight=1.0, colsample_bytree=1.0).fit(X_train, y_train)

geocp_classifier = GeoConformalClassifier(predict_f=model.predict_proba, x_calib=X_calib.values, y_calib=y_calib, coord_calib=loc_calib.values, bandwidth=0.2, miscoverage_level=0.1, nonconformity_score='aps')

results = geocp_classifier.geo_conformalize(X_test.values, y_test.values, loc_test.values)

This repository hosts the code base for the paper

GeoConformal prediction: a model-agnostic framework of measuring the uncertainty of spatial prediction
Xiayin Lou, Peng Luo, Liqiu Meng
Annals of the American Association of Geographers
Link to Paper

If you find this work useful, please consider cite:

@article{lou2025geoconformal,
  title={GeoConformal Prediction: a model-agnostic framework for measuring the uncertainty of spatial prediction},
  author={Lou, Xiayin and Luo, Peng and Meng, Liqiu},
  journal={Annals of the American Association of Geographers},
  pages={1--28},
  year={2025},
  publisher={Taylor \& Francis}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages