gwlearn.base.BaseClassifier#
- class gwlearn.base.BaseClassifier(model, bandwidth, fixed=False, kernel='bisquare', n_jobs=-1, fit_global_model=True, measure_performance=True, strict=False, keep_models=False, temp_folder=None, batch_size=None, min_proportion=0.2, **kwargs)[source]#
Generic geographically weighted modelling meta-class
NOTE: local models leave out focal, unlike in traditional approaches. This allows assessment of geographically weighted metrics on unseen data without a need for train/test split, hence providing value for all samples. This is needed for futher spatial analysis of the model performance (and generalises to models that do not support OOB scoring).
- Parameters:
- model
model
class
Scikit-learn model class
- bandwidth
int
|float
bandwidth value consisting of either a distance or N nearest neighbors
- fixedbool,
optional
True for distance based bandwidth and False for adaptive (nearest neighbor) bandwidth, by default False
- kernel
str
,optional
type of kernel function used to weight observations, by default “bisquare”
- n_jobs
int
,optional
The number of jobs to run in parallel.
-1
means using all processors by default-1
- fit_global_modelbool,
optional
Determines if the global baseline model shall be fitted alognside the geographically weighted, by default True
- strictbool |
None
,optional
Do not fit any models if at least one neighborhood has invariant
y
, by default None. None is treated as False but provides a warning if there are invariant models.- keep_modelsbool |
str
|Path
,optional
Keep all local models (required for prediction), by default False. Note that for some models, like random forests, the objects can be large. If string or Path is provided, the local models are not held in memory but serialized to the disk from which they are loaded in prediction.
- temp_folder
str
,optional
Folder to be used by the pool for memmapping large arrays for sharing memory with worker processes, e.g.,
/tmp
. Passed tojoblib.Parallel
.- **kwargs
Additional keyword arguments passed to
model
initialisation
- model
- __init__(model, bandwidth, fixed=False, kernel='bisquare', n_jobs=-1, fit_global_model=True, measure_performance=True, strict=False, keep_models=False, temp_folder=None, batch_size=None, min_proportion=0.2, **kwargs)[source]#
Methods
__init__
(model, bandwidth[, fixed, kernel, ...])fit
(X, y, geometry)Fit the geographically weighted model
predict
(X, geometry)predict_proba
(X, geometry)Predict probabiliies using the ensemble of local models
- fit(X, y, geometry)[source]#
Fit the geographically weighted model
- Parameters:
- X
pd.DataFrame
Independent variables
- y
pd.Series
Dependent variable
- geometry
gpd.GeoSeries
Geographic location
- X
- predict_proba(X, geometry)[source]#
Predict probabiliies using the ensemble of local models
For any given location, this uses the
- Parameters:
- X
pd.DataFrame
_description_
- geometry
gpd.GeoSeries
_description_
- X
- Returns:
pd.DataFrame
_description_
- Raises:
NotImplementedError
_description_