GEO-INFER-AI
Instructions
Core Capabilities
- ML pipelines: Spatial feature engineering → training → evaluation with scikit-learn
- Geospatial active inference: H3-grid environmental modeling and belief
updating via EnvironmentalActiveInferenceEngine; multi-scale hierarchical
spatial analysis via MultiScaleHierarchicalAnalyzer with Gaussian-process
and DBSCAN spatial methods
- Model selection: Cross-validation, hyperparameter search, spatial block cross-validation
- Spatial features: Coordinate-based features (distances, angles, spatial lag)
- Spatial interpolation: IDW and Ordinary Kriging with prediction variance
- Explainability: Permutation importance, SHAP-like values, partial dependence
- MLOps: Optional MLflow experiment tracking (graceful degradation without it)
Key Imports
from geo_infer_ai import (
ModelTrainer,
TrainingConfig,
GeospatialModelEvaluator,
ImageClassifier,
SpatialPredictor,
IDWInterpolator,
OrdinaryKriging,
GeospatialFeatureEngineer,
ModelExplainer,
MLflowPipeline,
EnvironmentalActiveInferenceEngine,
MultiScaleHierarchicalAnalyzer,
)
Examples
Train and spatially cross-validate a model:
from sklearn.ensemble import RandomForestRegressor
from geo_infer_ai import GeospatialModelEvaluator
model = RandomForestRegressor(n_estimators=50, random_state=42)
evaluator = GeospatialModelEvaluator()
results = evaluator.cross_validate_spatial(model, X, y, coordinates, n_splits=3)
print(results["mean_score"], results["std_score"])
Fit an IDW interpolator:
import numpy as np
from geo_infer_ai import IDWInterpolator
coords = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
values = np.array([10.0, 20.0, 30.0])
interpolator = IDWInterpolator(power=2.0).fit(coords, values)
pred = interpolator.predict(np.array([[0.5, 0.5]]))
Spatial feature engineering:
from geo_infer_ai import GeospatialFeatureEngineer
engineer = GeospatialFeatureEngineer(normalize=True)
features = engineer.create_spatial_features(coordinates, include_distances=True)
Agent interfaces
Use uv run --frozen geo-infer catalog AI to discover public source
APIs, then geo-infer describe before calling a selected target. Scripts use
geo_infer_api.agent_runtime.AgentSession; the optional stdio MCP server is
geo-infer-mcp. See requests, native objects and composition.
The adapter retains this module's dependencies and authorization requirements.
Guidelines
- Use
cross_validate_spatial(not shuffled K-fold) when samples are spatially
autocorrelated — it blocks contiguous regions to prevent spatial leakage.
- Kriging
predictreturns(values, variances); use the variances for
prediction-uncertainty estimates.
GeospatialFeatureEngineerdoes not correct for spatial autocorrelation;
it is handled by spatial models and block CV.
Integrations
- Standalone: depends only on numpy, pandas, scikit-learn, h3
- Optional MLflow tracking via the
mlopsextra (MLflowPipelinedegrades
gracefully to disabled mode when MLflow is absent)
- GEO-INFER-MATH provides the config-driven general-purpose interpolation
counterparts (see geo_infer_ai.models.predictive docstring for the
deliberate API differences)
- Test:
uv run python GEO-INFER-TEST/run_unified_tests.py --module AI
Value-tolerance evaluation
Use GeospatialModelEvaluator.evaluate_value_tolerance(y_true, y_pred, tolerance)
for absolute target-value errors and the percentage within a tolerance expressed
in target units. It replaces evaluate_spatial_accuracy; it accepts no coordinates
or geographic buffer argument. Inputs must be matching finite nonempty vectors.