gwlearn.search.BandwidthSearch#
- class gwlearn.search.BandwidthSearch(model, *, fixed=False, kernel='bisquare', geometry=None, n_jobs=-1, search_method='golden_section', criterion='aicc', metrics=None, minimize=True, min_bandwidth=None, max_bandwidth=None, interval=None, max_iterations=100, tolerance=0.01, verbose=False, **kwargs)[source]#
Optimal bandwidth search for geographically-weighted models
Reports information criteria and (optionally) other scores from multiple models with varying bandwidth. When using golden section search, minimizes one of AIC, AICc, BIC based on prediction probability on focal geometries.
When using classification models with a defined
min_proportion, keep in mind that some locations may be excluded from the final model. In such a case, the information criteria are typically not comparable across models with different bandwidths and shall not be used to determine the optimal one.- Parameters:
- model
modelclass Scikit-learn model class or compatible estimator.
- fixedbool,
optional True for distance based bandwidth and False for adaptive (nearest neighbor) bandwidth, by default
False- kernel
str|Callable,optional Type of kernel function used to weight observations, by default
"bisquare"- n_jobs
int,optional The number of jobs to run in parallel.
-1means using all processors, by default-1- search_method{“golden_section”, “interval”},
optional Method used to search for optimal bandwidth. When using
"golden_section", the Golden section optimization is used to find the optimal bandwidth while attempting to minimize or maximisecriterion. When using"interval", fits all models within the specified bandwidths at a set interval without any attempt to optimize the selection. By default"golden_section".- criterion
str,optional Vriterion used to select optimal bandwidth. Can be one of
{"aicc", "aic", "bic"}or any ofmetrics. By default"aicc".- metrics
list[str] |None,optional List of additional metrics beyond
criterionto be reported. Has to be a metric supported bymodel, passable tomeasure_performanceargument of model’s initialization or ‘prediction_rate’. By defaultNone.- minimizebool,
optional Minimize or maximize the
criterion. When using information criterions, like AICc, the optimal solution is the lowest value. When using other metrics, the optimal may the the highest value. By default True, assuming lower is better.- min_bandwidth
int|float|None,optional Minimum bandwidth to consider, by default
None- max_bandwidth
int|float|None,optional Maximum bandwidth to consider, by default
None- interval
int|float|None,optional Interval for bandwidth search when using “interval” method, by default
None- max_iterations
int,optional Maximum number of iterations for golden section search, by default
100- tolerance
float,optional Tolerance for convergence in golden section search, by default
1e-2- verbosebool |
int,optional Verbosity level, by default False
- **kwargs
Additional keyword arguments passed to
modelinitialization
- model
- Attributes:
- __init__(model, *, fixed=False, kernel='bisquare', geometry=None, n_jobs=-1, search_method='golden_section', criterion='aicc', metrics=None, minimize=True, min_bandwidth=None, max_bandwidth=None, interval=None, max_iterations=100, tolerance=0.01, verbose=False, **kwargs)[source]#
Methods