ScalableGWR¶
This page documents 1 public symbols. Each entry includes its purpose, import path, full API docstring, and the maintained example that exercises it.
ScalableGWR¶
Scalable GWR using a linear multiscale polynomial kernel.
| Property | Value |
|---|---|
| Type | class |
| Import | from pygwrx.models import ScalableGWR |
| Signature | ScalableGWR(bandwidth: 'int' = 100, kernel: 'str' = 'gaussian', polynomial: 'int' = 4, criterion: 'str' = 'cv', optimize_bandwidth: 'bool' = True, scale: 'Optional[float]' = None, penalty: 'Optional[float]' = None, fit_intercept: 'bool' = True, sample_size: 'Optional[int]' = None, random_state: 'Optional[int]' = None, optimizer_maxiter: 'int' = 200, numerical_jitter: 'float' = 0.0, verbose: 'bool' = False) -> 'None' |
| Maintained example | examples/models/12_scalable_gwr.py |
ScalableGWR ¶
ScalableGWR(
bandwidth: int = 100,
kernel: str = "gaussian",
polynomial: int = 4,
criterion: str = "cv",
optimize_bandwidth: bool = True,
scale: Optional[float] = None,
penalty: Optional[float] = None,
fit_intercept: bool = True,
sample_size: Optional[int] = None,
random_state: Optional[int] = None,
optimizer_maxiter: int = 200,
numerical_jitter: float = 0.0,
verbose: bool = False,
)
Scalable GWR using a linear multiscale polynomial kernel.
ScaGWR approximates a continuous Gaussian or exponential kernel by a
weighted sum of polynomially transformed base kernels. Only bandwidth
nearest neighbours are used for local cross-products, while penalty
adds a global OLS cross-product term. The large local cross-products are
computed once, before optimization, so calibration remains linear in the
number of observations for fixed feature count, polynomial degree, and
neighbour count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bandwidth
|
int
|
Number of nearest neighbours, denoted Q in the paper. |
100
|
kernel
|
str
|
Base kernel, either |
'gaussian'
|
polynomial
|
int
|
Polynomial degree used to approximate the kernel. |
4
|
criterion
|
str
|
Parameter-calibration criterion, |
'cv'
|
optimize_bandwidth
|
bool
|
Optimize scale and penalty parameters. The neighbour count itself is fixed in ScaGWR and is not optimized. |
True
|
scale
|
Optional[float]
|
Fixed positive scale parameter when optimization is disabled, or optional initial value when optimization is enabled. |
None
|
penalty
|
Optional[float]
|
Fixed non-negative global shrinkage parameter when optimization is disabled, or optional initial value when optimization is enabled. |
None
|
fit_intercept
|
bool
|
Add a spatially varying intercept. |
True
|
sample_size
|
Optional[int]
|
Optional number of target sites used during CV calibration. All observations remain available as neighbours and in the global shrinkage term. Ignored for AICc calibration. |
None
|
random_state
|
Optional[int]
|
Random seed used when |
None
|
optimizer_maxiter
|
int
|
Maximum L-BFGS-B iterations. |
200
|
numerical_jitter
|
float
|
Explicit diagonal stabilization added to every local system after the published global penalty term. |
0.0
|
verbose
|
bool
|
Print calibration information. |
False
|
Notes
The historical pyGWRx class with this name was a kNN-truncated ordinary GWR that still formed a full distance matrix. It was not ScaGWR. This class implements the published polynomial-kernel estimator instead.
Source code in src/pygwrx/models/scalable_gwr.py
fit ¶
fit(
X: Union[ndarray, DataFrame],
y: Union[ndarray, Series],
coords: Union[ndarray, DataFrame],
) -> "ScalableGWR"
Fit the published ScaGWR estimator.
Source code in src/pygwrx/models/scalable_gwr.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | |
predict_result ¶
predict_result(
X: Optional[Union[ndarray, DataFrame]],
coords: Union[ndarray, DataFrame],
*,
return_standard_errors: bool = False
) -> ScalableGWRPredictionResult
Estimate coefficients and optionally predictions at new locations.
Source code in src/pygwrx/models/scalable_gwr.py
predict ¶
Predict responses by estimating ScaGWR coefficients at new locations.
Source code in src/pygwrx/models/scalable_gwr.py
to_frame ¶
Return training-location coefficients, inference, and fit diagnostics.
Source code in src/pygwrx/models/scalable_gwr.py
summary ¶
Return fitted diagnostics as a plain-text table.
Runnable examples used on this page¶
examples/models/12_scalable_gwr.py
# SPDX-FileCopyrightText: 2026 Jinghao Hu
# SPDX-License-Identifier: MIT
"""Fit scalable GWR with a fixed multiscale-kernel approximation."""
# 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 print_model_result, spatial_regression
from pygwrx import ScalableGWR
X, y, coords = spatial_regression(n=54, p=2)
model = ScalableGWR(
bandwidth=24, optimize_bandwidth=False, polynomial=4, random_state=0
).fit(X, y, coords)
print_model_result(model)
print("predictions=", model.predict(X.iloc[:3], coords.iloc[:3]))