Gnnwr logo

Gnnwr

Community
SteadfastAsArt
gnnwr

Spatial and spatiotemporal regression with GNNWR (Geographically Neural Network Weighted Regression). Use when the agent needs to: (1) Build spatially varying coefficient regression models, (2) Analyze geographic non-stationarity in spatial data, (3) Generate spatial coefficient maps for publication, (4) Run spatiotemporal regression with GTNNWR, (5) Scale geographically weighted regression to large datasets (N > 10k) with KNN mode, (6) Diagnose spatial model performance with F-tests, AIC, and residual maps.

Overview

PublisherSteadfastAsArt
Repositorygeoscience-skills
Skill namegnnwr
Stars
75
Forks
9
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by SteadfastAsArt on GitHub. Read the source before you install it.

Installation

Install the Gnnwr AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/SteadfastAsArt/geoscience-skills/tree/main/gnnwr
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SteadfastAsArt/geoscience-skills.git /tmp/geoscience-skills
mkdir -p .claude/skills
cp -r /tmp/geoscience-skills/gnnwr .claude/skills/gnnwr
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Gnnwr in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Gnnwr on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Gnnwr is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

GNNWR - Geographically Neural Network Weighted Regression

Quick Reference

python
from gnnwr import models, datasets, utils
import pandas as pd

data = pd.read_csv("data.csv")

train, val, test = datasets.init_dataset(
    data=data, test_ratio=0.2, valid_ratio=0.1,
    x_column=["x1", "x2", "x3"], y_column=["y"],
    spatial_column=["lon", "lat"],  # REQUIRED: geographic coords
    batch_size=32, process_fn="minmax_scale"
)

model = models.GNNWR(train, val, test, use_gpu=True, optimizer="Adam", start_lr=0.01)
model.run(max_epoch=200, early_stop=30)

result = model.reg_result(only_return=True)  # DataFrame: coef_x1, coef_x2, ..., Pred_y
print(model.result())                         # R², AIC, RMSE, F-tests summary

Spatiotemporal (GTNNWR)

python
train, val, test = datasets.init_dataset(
    data=data, ...,
    spatial_column=["lon", "lat"],
    temp_column=["year", "month"],  # add temporal coords
    use_model="gtnnwr"
)
model = models.GTNNWR(train, val, test, use_gpu=True)

Large-Scale (N > 10k) — KNN Mode

python
train, val, test = datasets.init_dataset(
    data=data, ..., knn_k=500  # only k nearest neighbor distances
)
# Memory: N=100k full=55GB → knn_k=2000 only 763MB

Key Classes

ClassPurpose
models.GNNWRSpatial regression with neural network geographic weighting
models.GTNNWRSpatiotemporal regression with temporal + spatial weighting
datasets.init_datasetData splitting, normalization, distance matrix construction
utils.VisualizeBuilt-in folium interactive maps for coefficients and predictions

Essential Operations

init_dataset Parameters

ParameterDefaultNotes
knn_kNoneKNN sparse distance; None=full matrix
process_fn"minmax_scale"or "standard_scale"
spatial_funBasicDistanceEuclidean; or ManhattanDistance
ReferenceNone"train", "train_val", or custom DataFrame
sample_seed42Reproducibility

Model Hyperparameters

ParameterRecommendedNotes
optimizer"Adam"Also: SGD, AdamW, Adagrad, RMSprop
start_lr0.01–0.1Critical tuning point
drop_out0.20.0–0.5
dense_layersNone (auto)Auto: power-of-2 sequence from input_dim to n_coef
early_stop20–50Patience; -1=disabled
batch_normTrueStabilizes training
use_olsTrueOLS-initialized output layer

Diagnostics

python
diag = model._test_diagnosis
diag.R2()           # always available
diag.RMSE()         # always available
diag.AIC()          # needs lite=False (auto for N<10k)
diag.AICc()         # corrected AIC
diag.F1_Global()    # GNNWR vs OLS significance
diag.F2_Global()    # spatial weight significance
diag.F3_Local()     # per-variable significance → (dict1, dict2)

lite=True (auto when N>10k): only R²/RMSE; Hat-matrix diagnostics skipped.

Visualization Patterns

Folium Interactive Maps (built-in)

python
viz = utils.Visualize(model, lon_lat_columns=["lon", "lat"], zoom=5)
m1 = viz.display_dataset(name="all", y_column="y")
m1.save("dataset_map.html")

for col in [c for c in result.columns if c.startswith("coef_")]:
    m = viz.coefs_heatmap(data_column=col, steps=20)
    m.save(f"map_{col}.html")

Matplotlib Static Maps (publication-ready)

python
import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 3, figsize=(18, 12))
coef_cols = [c for c in result.columns if c.startswith("coef_")]

for ax, col in zip(axes.flat, coef_cols):
    sc = ax.scatter(
        result["lon"], result["lat"],
        c=result[col], cmap="RdYlBu_r", s=5, alpha=0.8,
        vmin=result[col].quantile(0.02), vmax=result[col].quantile(0.98)
    )
    ax.set_title(col.replace("coef_", "β_"), fontsize=14)
    plt.colorbar(sc, ax=ax, shrink=0.8)

plt.suptitle("Spatially Varying Coefficients (GNNWR)", fontsize=16)
plt.tight_layout()
plt.savefig("coefficients_map.png", dpi=300, bbox_inches="tight")

GeoPandas + Contextily (with basemap)

python
import geopandas as gpd
import contextily as ctx

gdf = gpd.GeoDataFrame(result, geometry=gpd.points_from_xy(result.lon, result.lat), crs="EPSG:4326")
gdf_web = gdf.to_crs(epsg=3857)

fig, ax = plt.subplots(figsize=(12, 10))
gdf_web.plot(column="coef_x1", ax=ax, cmap="RdYlBu_r", legend=True,
             markersize=5, alpha=0.7, legend_kwds={"shrink": 0.6})
ctx.add_basemap(ax, source=ctx.providers.CartoDB.Positron)
ax.set_title("β_x1 Spatial Variation")
ax.set_axis_off()
plt.savefig("coef_basemap.png", dpi=300, bbox_inches="tight")

When to Use vs Alternatives

Use CaseToolWhy
Spatially varying coefficients (neural net)GNNWRNon-linear weighting, scalable, coefficient maps
Classical geographically weighted regressionmgwr / GWR4Traditional bandwidth-based, well-established theory
Spatial interpolation (no covariates)verde / scikit-gstatGridding / kriging without regression
Global regression baselinestatsmodels / scikit-learnNo spatial non-stationarity assumed
Spatiotemporal varying coefficientsGTNNWRGNNWR extended with temporal dimension
Large-scale spatial regression (N > 100k)GNNWR + knn_kSparse distance matrix, O(n·k²) diagnostics
Geostatistical simulationgeostatspy / SGeMSStochastic realizations, uncertainty quantification

Choose GNNWR when: You need spatially varying regression coefficients with neural network-based geographic weighting, especially for large datasets where classical GWR is computationally infeasible.

Choose classical GWR when: You need well-established inferential statistics, bandwidth-based weighting, and simpler model interpretation.

Choose verde/kriging when: You need spatial interpolation without explanatory variables — pure spatial prediction from observed values.

Common Workflows

Spatial Regression Analysis

  • EDA: Check spatial distribution, feature correlations, OLS baseline
  • Data split: init_dataset with appropriate ratios and sample_seed=42
  • Train: Start with defaults, tune start_lr and early_stop
  • Diagnose: R², RMSE, F1 (GNNWR vs OLS), F2 (spatial weight significance)
  • Visualize: Coefficient maps, residual spatial distribution, pred vs obs
  • Interpret: Where do coefficients vary most? Which variables show strongest non-stationarity? (F3_Local)
  • Report: Model summary table + coefficient maps + diagnostic statistics

Common Issues

IssueSolution
Model degenerates to global regressionForgot spatial_column — always pass it
OOM on distance matrixN > 10k without knn_k; use knn_k=500–2000
Loss explodes during trainingstart_lr too high; start with 0.01
OverfittingNo early_stop; always set 20–50
Coefficients on wrong scaleUse reg_result() for denormalized predictions
GTNNWR behaves like GNNWRMissing temp_column; silently falls back

References

  • Diagnostics — DIAGNOSIS methods, F-tests, residual analysis
  • Visualization — Detailed visualization patterns and publication figures

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Gnnwr AI skill do?

Spatial and spatiotemporal regression with GNNWR (Geographically Neural Network Weighted Regression). Use when the agent needs to: (1) Build spatially varying coefficient regression models, (2) Analyze geographic non-stationarity in spatial data, (3) Generate spatial coefficient maps for publication, (4) Run spatiotemporal regression with GTNNWR, (5) Scale geographically weighted regression to large datasets (N > 10k) with KNN mode, (6) Diagnose spatial model performance with F-tests, AIC, and residual maps.

Why use Gnnwr on TypingMind?

Because you install it once and use it with any model. Gnnwr is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Gnnwr in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/SteadfastAsArt/geoscience-skills/tree/main/gnnwr. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Gnnwr?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Gnnwr?

As many as you like. As long as a model supports skills, you can use Gnnwr with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Gnnwr AI skill free?

Yes. It is published on GitHub by SteadfastAsArt under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇