def fit_from_geodataframe(self, gdf, attr, spatially_extensive_attr, threshold, max_it=10, objective_func=ObjectiveFunctionPairwise(), contiguity="rook"): """ Alternative API for :meth:`fit_from_scipy_sparse_matrix:. Parameters ---------- gdf : :class:`geopandas.GeoDataFrame` attr : str or list The clustering criteria (columns of the GeoDataFrame `gdf`) are specified as string (for one column) or list of strings (for multiple columns). spatially_extensive_attr : str or list The name (`str`) or names (`list` of strings) of column(s) in `gdf` containing the spatially extensive attributes. threshold : numbers.Real or :class:`numpy.ndarray` Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. max_it : int, default: 10 Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. objective_func : :class:`region.ObjectiveFunction`, default: ObjectiveFunctionPairwise() Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. contiguity : {"rook", "queen"}, default: "rook" Defines the contiguity relationship between areas. Possible contiguity definitions are: * "rook" - Rook contiguity. * "queen" - Queen contiguity. """ w = w_from_gdf(gdf, contiguity) attr = array_from_df_col(gdf, attr) spat_ext_attr = array_from_df_col(gdf, spatially_extensive_attr) self.fit_from_w(w, attr, spat_ext_attr, threshold=threshold, max_it=max_it, objective_func=objective_func)
def fit_from_geodataframe(self, gdf, attr, spatially_extensive_attr, threshold, solver="cbc", metric="euclidean", contiguity="rook"): """ Alternative API for :meth:`fit_from_scipy_sparse_matrix`. Parameters ---------- gdf : GeoDataFrame attr : str or list The clustering criteria (columns of the GeoDataFrame `gdf`) are specified as string (for one column) or list of strings (for multiple columns). spatially_extensive_attr : str or list The name (`str`) or names (`list` of strings) of column(s) in `gdf` containing the spatially extensive attributes. threshold : numbers.Real or :class:`numpy.ndarray` Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. solver : {"cbc", "cplex", "glpk", "gurobi"}, default: "cbc" Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. metric : str or function, default: "euclidean" Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. contiguity : {"rook", "queen"}, default: "rook" Defines the contiguity relationship between areas. Possible contiguity definitions are: * "rook" - Rook contiguity. * "queen" - Queen contiguity. """ w = w_from_gdf(gdf, contiguity) attr = array_from_df_col(gdf, attr) spat_ext_attr = array_from_df_col(gdf, spatially_extensive_attr) self.fit_from_w(w, attr, spat_ext_attr, threshold=threshold, solver=solver, metric=metric)
def fit_from_geodataframe(self, gdf, attr, n_regions, method="flow", solver="cbc", metric="euclidean", contiguity="rook"): """ Alternative API for :meth:`fit_from_scipy_sparse_matrix:. Parameters ---------- gdf : GeoDataFrame attr : str or list The clustering criteria (columns of the GeoDataFrame `gdf`) are specified as string (for one column) or list of strings (for multiple columns). n_regions : int See the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. method : str See the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. solver : str See the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. contiguity : {"rook", "queen"}, default: "rook" Defines the contiguity relationship between areas. Possible contiguity definitions are: * "rook" - Rook contiguity. * "queen" - Queen contiguity. metric : str or function, default: "euclidean" See the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. """ w = w_from_gdf(gdf, contiguity) attr = array_from_df_col(gdf, attr) self.fit_from_w(w, attr, n_regions, method=method, solver=solver, metric=metric)
def fit_from_geodataframe(self, gdf, attr, n_regions, contiguity="rook", initial_labels=None, cooling_factor=0.85, objective_func=ObjectiveFunctionPairwise()): """ Parameters ---------- gdf : :class:`geopandas.GeoDataFrame` Refer to the corresponding argument in :meth:`AZP.fit_from_geodataframe`. attr : `str` or `list` Refer to the corresponding argument in :meth:`AZP.fit_from_geodataframe`. n_regions : `int` Refer to the corresponding argument in :meth:`AZP.fit_from_geodataframe`. contiguity : `str` Refer to the corresponding argument in :meth:`AZP.fit_from_geodataframe`. initial_labels : :class:`numpy.ndarray` or None, default: None Refer to the corresponding argument in :meth:`AZP.fit_from_geodataframe`. cooling_factor : float, default: 0.85 Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. objective_func : :class:`region.ObjectiveFunction`, default: ObjectiveFunctionPairwise() Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. """ w = w_from_gdf(gdf, contiguity) attr = array_from_df_col(gdf, attr) self.fit_from_w( w, attr, n_regions, initial_labels, cooling_factor=cooling_factor, objective_func=objective_func)
def fit_from_geodataframe(self, gdf, attr, n_regions, contiguity="rook", initial_labels=None, objective_func=ObjectiveFunctionPairwise()): """ Alternative API for :meth:`fit_from_scipy_sparse_matrix`. Parameters ---------- gdf : :class:`geopandas.GeoDataFrame` attr : `str` or `list` The clustering-relevant attributes (columns of the GeoDataFrame `gdf`) are specified as string (for one column) or list of strings (for multiple columns). n_regions : `int` Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. contiguity : {"rook", "queen"}, default: "rook" Defines the contiguity relationship between areas. Possible contiguity definitions are: * "rook" - Rook contiguity. * "queen" - Queen contiguity. initial_labels : :class:`numpy.ndarray` or None, default: None Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. objective_func : :class:`region.ObjectiveFunction`, default: ObjectiveFunctionPairwise() Refer to the corresponding argument in :meth:`fit_from_scipy_sparse_matrix`. """ w = w_from_gdf(gdf, contiguity) attr = array_from_df_col(gdf, attr) self.fit_from_w( w, attr, n_regions, initial_labels, objective_func=objective_func)