geosnap.Community.cluster¶
-
Community.
cluster
(self, n_clusters=6, method=None, best_model=False, columns=None, verbose=False, scaler='std', pooling='fixed', **kwargs)[source]¶ Create a geodemographic typology by running a cluster analysis on the study area’s neighborhood attributes.
- Parameters
- n_clusters
int
, required the number of clusters to model. The default is 6).
- method
str
in
[‘kmeans’, ‘ward’, ‘affinity_propagation’, ‘spectral’, ‘gaussian_mixture’, ‘hdbscan’], required the clustering algorithm used to identify neighborhood types
- best_modelbool, optional
if using a gaussian mixture model, use BIC to choose the best n_clusters. (the default is False).
- columnsarray_like, required
subset of columns on which to apply the clustering
- verbosebool, optional
whether to print warning messages (the default is False).
- scaler
None
orscaler
fromsklearn.preprocessing
, optional a scikit-learn preprocessing class that will be used to rescale the data. Defaults to sklearn.preprocessing.StandardScaler
- pooling[“fixed”, “pooled”, “unique”], optional (default=’fixed’)
How to treat temporal data when applying scaling. Options include:
fixed : scaling is fixed to each time period
pooled : data are pooled across all time periods
unique : if scaling, apply the scaler to each time period, then generate clusters unique to each time period.
- n_clusters
- Returns
geosnap.Community
a copy of input Community with neighborhood cluster labels appended as a new column. If the cluster is already present, the name will be incremented