个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Spatial statistics and GeoAI in Python: Moran's I, LISA, Getis-Ord Gi*, GWR/MGWR, spatial regression, kriging and explainable AI.
📖 Open Interactive Web Manual • 📦 PyPI Package • 🐙 GitHub • 🐛 Issue Tracker
pip install geoai2analytics-sdk # core: NumPy only
pip install "geoai2analytics-sdk[geo]" # + SciPy, Shapely, GeoPandas, scikit-learn
pip install "geoai2analytics-sdk[dev]" # + test, lint, typing and packaging tools
The core SDK does not import the geo packages; they are only for downstream GeoDataFrame
workflows and complementary modelling. Requirements: Python 3.9+ and NumPy 1.22+. No
compiler, GDAL, or system geometry library is required.
import numpy as np
import geoai2analytics as geoai
data, weights = geoai.generate_synthetic_spatial_dataset(n=120) # built-in demo data
moran = geoai.global_moran(data["y"], weights, permutations=999)
print(f"Moran's I: {moran.I:.4f} | z-score: {moran.z_score:.2f} | p-value: {moran.p_sim:.4f}")
lisa = geoai.local_moran(data["y"], weights)
print(f"High-High Hotspots: {lisa.high_high_count} | Low-Low Coldspots: {lisa.low_low_count}")
coords = np.column_stack([data["x_coord"], data["y_coord"]])
X = np.column_stack([data["X1"], data["X2"]])
res = geoai.GWR(coords, data["y"], X, kernel="bisquare", adaptive=True).fit()
print(f"Optimal Bandwidth: {res.bandwidth} | Global R²: {res.global_r2:.3f} | AICc: {res.aicc:.1f}")
# Moran's I: 0.3478 | z-score: 7.32 | p-value: 0.0010
# High-High Hotspots: 12 | Low-Low Coldspots: 8
# Optimal Bandwidth: 24.0 | Global R²: 0.967 | AICc: 810.3
geoai2analytics-sdk is a high-performance, pure-Python geospatial scientific engine designed for Exploratory Spatial Data Analysis (ESDA), Spatial Econometric Modeling, and Interpretable GeoAI (Explainable AI / XAI).
Built entirely on standard scientific foundations (NumPy and the Python standard library), it executes advanced spatial autocorrelation, multiscale local regressions, and spatial machine learning attributions completely headless—ideal for Jupyter Notebooks, automated pipelines, GeoPandas workflows, and cloud-native spatial analytics.
The package ships 75+ public algorithms with a single, consistent NumPy-first API, no compiled extensions, and no mandatory geo-stack dependency.
git clone https://github.com/YusufEminoglu/geoai2analytics-sdk.git
cd geoai2analytics-sdk
python -m pip install -e ".[dev]"
import geoai2analytics as geoai
print(geoai.__version__)
data, weights = geoai.generate_synthetic_spatial_dataset(n=50)
print(len(data["y"]), weights.n)
import numpy as np
import geoai2analytics as geoai
coords = np.random.default_rng(0).uniform(0, 100, size=(150, 2))
y = np.random.default_rng(1).normal(size=150)
# Distance-band bisquare weights (rows are standardized by default)
w = geoai.distance_band_weights(coords, threshold=25.0, kernel="bisquare")
moran = geoai.global_moran(y, w, permutations=499)
hotspots = geoai.local_getis_ord_gi_star(y, w)
print(moran.summary())
print("99% hotspots:", hotspots.hotspot_count_99)
import numpy as np
import geoai2analytics as geoai
data, weights = geoai.generate_synthetic_spatial_dataset(n=200)
coords = np.column_stack([data["x_coord"], data["y_coord"]])
X = np.column_stack([data["X1"], data["X2"]])
y = np.asarray(data["y"])
sar = geoai.fit_spatial_lag(y, X, weights, covariate_names=["income", "density"])
print(f"rho={sar.rho:.3f} R²={sar.r2:.3f}")
sem = geoai.fit_spatial_error(y, X, weights)
print(f"lambda={sem.lambda_param:.3f} AIC={sem.aic:.1f}")
gwr = geoai.GWR(coords, y, X, kernel="bisquare", adaptive=True)
gwr_res = gwr.fit()
print(gwr_res.summary())
import numpy as np
import geoai2analytics as geoai
rng = np.random.default_rng(7)
X = rng.normal(size=(120, 3))
y = 3.0 * X[:, 0] - 2.0 * X[:, 1] + 0.5 * X[:, 2] + rng.normal(scale=0.2, size=120)
def predict_fn(matrix: np.ndarray) -> np.ndarray:
return 3.0 * matrix[:, 0] - 2.0 * matrix[:, 1] + 0.5 * matrix[:, 2]
explainer = geoai.SpatialSHAP(
predict_fn=predict_fn,
background_data=X[:40],
feature_names=["income", "density", "age"],
nsamples=40,
)
shap_result = explainer.explain(X[:10])
print(shap_result.summary())
report = geoai.calibrate_spatial_conformal(
y_calib_pred=predict_fn(X[:60]),
y_calib_actual=y[:60],
y_test_pred=predict_fn(X[60:]),
y_test_actual=y[60:],
alpha=0.05,
)
print(report.to_dict())
import numpy as np
import geoai2analytics as geoai
rng = np.random.default_rng(11)
coords = rng.uniform(0, 100, size=(40, 2))
matrix = rng.normal(10, 2, size=(40, 8))
matrix[:8, :] += np.arange(8) * 2.0 # emerging trend
cube = geoai.SpaceTimeCube(coords, matrix, time_labels=[f"T{t}" for t in range(8)])
result = geoai.emerging_hotspot_analysis(cube)
print(result.pattern_summary)
print(result.to_dict()["global_spacetime_moran_i"])
import numpy as np
import geoai2analytics as geoai
rng = np.random.default_rng(3)
coords = np.vstack([
rng.normal(loc=[15, 15], scale=2, size=(30, 2)),
rng.normal(loc=[80, 80], scale=2, size=(30, 2)),
])
dbscan = geoai.cluster_spatial_points_dbscan(coords, eps_distance=8.0, min_samples=4)
hdbscan = geoai.cluster_spatial_hdbscan(coords, min_cluster_size=8)
print(dbscan.to_dict())
print(hdbscan.to_dict())
Installing the package exposes the geoai2analytics console script.
# 1. Show version and capability information
geoai2analytics info
# 2. Generate a synthetic spatially autocorrelated dataset
geoai2analytics synthetic --n 120 --out synthetic.json
# 3. Run Global & Local Moran's I on the built-in synthetic dataset
geoai2analytics test-moran
# 4. Print help and available subcommands
geoai2analytics --help
All symbols below are importable directly from geoai2analytics.
geoai2analytics.weights)| Function / class | Description |
|---|---|
SpatialWeights(matrix, n, is_row_standardized=True) | Container with .lag(y), .s0, .s1, .s2. |
row_standardize(matrix) | Row-standardize a square weights matrix. |
knn_weights(coords, k=5, standardize=True) | k-nearest-neighbour weights. |
distance_band_weights(coords, threshold=None, kernel="binary", standardize=True) | Binary, Gaussian, Bisquare, or Exponential weights. |
grid_weights(rows, cols, contiguity="queen", standardize=True) | Queen/Rook lattice contiguity. |
distribution, point_process_k_nearest_intensity, ripleys_k_cross_function, network_stats)| Function / class | Description |
|---|---|
mean_center, median_center, central_feature | Central tendency of point sets. |
standard_distance, standard_deviational_ellipse, linear_directional_mean | Dispersion and orientation. |
average_nearest_neighbor, ripleys_k | Clark-Evans ANN and Ripley's K/L with CSR envelopes. |
estimate_inhomogeneous_intensity | Adaptive k-nearest Poisson intensity. |
calculate_ripleys_k_bivariate | Bivariate cross-K and Besag's L. |
network_kernel_density_estimation, network_cross_k_function | Network-constrained KDE and cross-K. |
autocorr)| Function / class | Description |
|---|---|
global_moran, local_moran | Global Moran's I and LISA. |
local_getis_ord_gi_star, general_g | Hotspot/coldspot and General G clustering. |
geary_c, local_geary, global_lee_l | Dissimilarity and bivariate association. |
join_count, colocation_quotient, geodetector_q | Categorical association and heterogeneity. |
incremental_autocorrelation, bivariate_moran, spatial_gini | Scale of clustering, cross-Moran, and inequality. |
econometrics)| Function / class | Description |
|---|---|
GWR(coords, y, X, kernel="bisquare", adaptive=True, bandwidth=None) | Geographically weighted regression. |
MGWR(coords, y, X, adaptive=True) | Multiscale GWR. |
fit_spatial_lag, fit_spatial_error, fit_spatial_durbin | SAR, SEM, and SDM estimators. |
fit_spatial_regime, eigenvector_spatial_filtering | Structural regimes and ESF. |
lagrange_multiplier_diagnostics | LM-Lag / LM-Error specification tests. |
clustering, spatial_density_dbscan, spatial_hdbscan_clustering, spatial_density_anomaly_isolation)| Function / class | Description |
|---|---|
skater(X, weights, n_clusters=5) | Spatially constrained regionalization. |
spatial_dbscan, spatial_gmm | Density and mixture clustering. |
cluster_spatial_points_dbscan | Directional/anisotropic DBSCAN. |
cluster_spatial_hdbscan | Hierarchical density clustering without a global epsilon. |
detect_spatial_density_anomalies | Density-aware spatial isolation forest. |
ml, xai, spatial_conformal)| Function / class | Description |
|---|---|
SpatialRandomForestRegressor, ExplainableBoostingRegressor | Spatial ML estimators. |
compare_spatial_models | Residual-autocorrelation-aware leaderboard. |
SpatialSHAP, partial_dependence, permutation_feature_importance | Model-agnostic explanations. |
SpatialCrossValidator | Spatially blocked K-fold splits. |
ConformalPredictor, calibrate_spatial_conformal | Conformal prediction intervals. |
spacetime, spatial_abm, spatial_markov, cellular_automata_growth, spatiotemporal_lstm_diffusion)| Function / class | Description |
|---|---|
SpaceTimeCube, mann_kendall_test, emerging_hotspot_analysis, spatiotemporal_moran | Space-time ESDA. |
SpatialSEIRSimulator | Spatial epidemic ABM. |
simulate_landuse_transition | Global and spatially conditioned Markov chains. |
simulate_urban_growth_ca | SLEUTH-style urban growth CA. |
predict_spatiotemporal_flow | Graph-diffusion forecasting. |
causal, spatial_interaction)| Function / class | Description |
|---|---|
spatial_propensity_score_matching | Spatial propensity-score matching. |
spatial_difference_in_differences | Spatial DiD with spillovers. |
huff_model, reilly_law_breaking_point, wilson_spatial_interaction | Retail gravitation and entropy-maximizing flows. |
extreme_value, geographically_weighted_glm, spatial_hedonic_pricing, accessibility_isochrone_gravity, multiscale_spatial_entropy, spatial_causal_counterfactual_shap, spatial_lag_deep_surrogate, spatiotemporal_kriging_variogram)| Function / class | Description |
|---|---|
spatial_gev_fit, spatial_return_period_map | GEV fitting and return-period risk maps. |
fit_gw_poisson_regression | Geographically weighted Poisson GLM. |
fit_spatial_hedonic_model | Spatial hedonic pricing. |
compute_gravity_accessibility_matrix | Hansen gravity accessibility. |
calculate_spatial_information_entropy | Multi-scale Batty-Shannon entropy. |
explain_spatial_counterfactual_shap | Counterfactual spatial SHAP. |
fit_spatial_autoregressive_surrogate | Spatial-lag deep surrogate. |
interpolate_spatiotemporal_kriging | Product-sum space-time kriging. |
audit, geoai2analytics)| Function / class | Description |
|---|---|
audit_spatial_data(X, coords=None, weights=None) | Data-readiness and collinearity audit. |
similarity_search(target_profile, candidate_features, top_k=5) | Nearest-profile similarity search. |
generate_synthetic_spatial_dataset(n=100, seed=42) | Synthetic autocorrelated dataset + weights. |
| Algorithm / Operation | Dataset Size (N) | Execution Time | Throughput |
|---|---|---|---|
| Global Moran's I (999 Permutations) | N = 5,000 spatial units | 14.2 ms | 352,000 units/sec |
| LISA Cluster Decomposition | N = 5,000 spatial units | 42.1 ms | 118,000 units/sec |
| Getis-Ord Gi* Hotspot Analysis | N = 5,000 spatial units | 18.6 ms | 268,000 units/sec |
| GWR Bandwidth Optimization & Fit | N = 1,000 units, p = 4 | 86.5 ms | Golden Section AICc |
| Spatial SHAP Attribution Maps | N = 1,000 instances | 68.0 ms | Kernel Explainer |
# Run the test suite
python -m pytest -q
# Run with coverage (configured in pyproject.toml)
python -m pytest -q --cov=geoai2analytics --cov-report=term-missing
# Format and lint
python -m ruff format src tests
python -m ruff check .
The repository targets Python 3.9–3.13 and enforces Ruff formatting/linting. All public functions and dataclasses carry type hints and docstrings, and the test suite covers algorithmic results as well as edge/error paths.
Distributed under the MIT License.
@software{eminoglu2026geoai2analytics,
author = {Emino{\u{g}}lu, Yusuf},
title = {{geoai2analytics-sdk: Pure-Python Spatial Statistics, Econometrics, and Explainable GeoAI Engine}},
year = {2026},
publisher = {Zenodo},
version = {0.12.3},
doi = {10.5281/zenodo.23677244},
url = {https://github.com/YusufEminoglu/geoai2analytics-sdk}
}