GWSS¶
This page documents 1 public symbols. Each entry includes its purpose, import path, full API docstring, and the maintained example that exercises it.
GWSS¶
Compute geographically weighted summary statistics.
| Property | Value |
|---|---|
| Type | class |
| Import | from pygwrx.models import GWSS |
| Signature | GWSS(kernel: 'str \| Any' = 'bisquare', bandwidth: 'float \| int \| None' = None, adaptive: 'bool' = False, quantile: 'bool' = False, verbose: 'bool' = False) -> 'None' |
| Maintained example | examples/models/11_gwss.py |
GWSS ¶
GWSS(
kernel: str | Any = "bisquare",
bandwidth: float | int | None = None,
adaptive: bool = False,
quantile: bool = False,
verbose: bool = False,
)
Compute geographically weighted summary statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
str | Any
|
Kernel name or callable accepted by
:func: |
'bisquare'
|
bandwidth
|
float | int | None
|
Positive fixed distance or, when |
None
|
adaptive
|
bool
|
Whether |
False
|
quantile
|
bool
|
Whether to calculate local median, interquartile range, and quantile imbalance. |
False
|
verbose
|
bool
|
Whether to print a compact completion message. |
False
|
Notes
Moment statistics follow GWmodel::gwss. In particular, local variance
is the normalized weighted second central moment, whereas bivariate
covariance uses the unbiased stats::cov.wt denominator
1 - sum(w**2). Weighted quantiles reproduce GWmodel's findq rule.
Source code in src/pygwrx/models/gwss.py
select_bandwidth ¶
select_bandwidth(
X: ndarray | DataFrame,
coords: ndarray | DataFrame,
*,
statistic: str = "mean"
) -> float | int
Select a shared bandwidth by leave-one-out CV.
The score sums the GWmodel mean- or median-CV scores over all variables.
This method returns one shared bandwidth suitable for gwss; GWmodel's
bw.gwss.average additionally reports variable-specific bandwidths.
Source code in src/pygwrx/models/gwss.py
fit ¶
fit(
X: ndarray | DataFrame,
coords: ndarray | DataFrame,
summary_coords: ndarray | DataFrame | None = None,
) -> "GWSS"
Calculate local summary statistics and store the fitted result.
Source code in src/pygwrx/models/gwss.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
summary ¶
Return a plain-text summary of the fitted local statistics.
Source code in src/pygwrx/models/gwss.py
to_dataframe ¶
Return local statistics in GWmodel-compatible column naming.
Source code in src/pygwrx/models/gwss.py
Runnable examples used on this page¶
examples/models/11_gwss.py
# SPDX-FileCopyrightText: 2026 Jinghao Hu
# SPDX-License-Identifier: MIT
"""Compute geographically weighted summary statistics."""
# Allow this script to run directly from any working directory.
import sys
from pathlib import Path
_PROJECT_ROOT = Path(__file__).resolve().parents[2]
_EXAMPLES_ROOT = _PROJECT_ROOT / "examples"
_SRC_ROOT = _PROJECT_ROOT / "src"
for _path in (_SRC_ROOT, _EXAMPLES_ROOT):
if str(_path) not in sys.path:
sys.path.insert(0, str(_path))
from _common import spatial_regression
from pygwrx import GWSS
X, _, coords = spatial_regression(n=48, p=3)
model = GWSS(bandwidth=24, adaptive=True, quantile=True).fit(X, coords)
print(model.summary())
print("local_means_shape=", model.local_mean_.shape)
print("local_correlation_pairs=", sorted(model.local_corr_))
print("first_correlation_shape=", next(iter(model.local_corr_.values())).shape)