Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region docs #214

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions spopt/region/azp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@ def __init__(self, spatially_extensive_attr, threshold, decorated_strategy):
Parameters
----------
spatially_extensive_attr : numpy.ndarray
See corresponding argument in
``region.max_p_regions.heuristics.MaxPRegionsHeu.fit_from_scipy_sparse_matrix``.
Values that will serve as domain for the threshold constraint
threshold : numbers.Real or numpy.ndarray
See corresponding argument in
``region.max_p_regions.heuristics.MaxPRegionsHeu.fit_from_scipy_sparse_matrix``
Value for the threshold constraint
decorated_strategy : AllowMoveStrategy
The ``AllowMoveStrategy`` related to the algorithms local search.
"""
Expand Down
7 changes: 5 additions & 2 deletions spopt/region/maxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
Journal of Geographical Information Science. Accepted 2020-04-12.
"""

__author__ = ["Ran Wei", "Serge Rey", "Elijah Knaap"]
__email__ = "[email protected]"

from ..BaseClass import BaseSpOptHeuristicSolver
from .base import (
w_to_g,
Expand Down Expand Up @@ -727,8 +730,8 @@ class MaxPHeuristic(BaseSpOptHeuristicSolver):
Set to ``True`` for reporting solution progress/debugging.
Default is ``False``.
Returns
-------
Attributes
----------
max_p : int
The number of regions.
Expand Down
30 changes: 21 additions & 9 deletions spopt/region/region_k_means.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""
Region k-means
K-means with the constraint that all clusters form a spatially connected component.
"""

__author__ = "Serge Rey"
__email__ = "[email protected]"


from collections import defaultdict
import numpy
from ..BaseClass import BaseSpOptHeuristicSolver
Expand All @@ -14,7 +25,7 @@


def region_k_means(X, n_clusters, w):
"""Solve the region-K-means problem, the K-means with the constraint
"""Solve the region-K-means problem with the constraint
that each cluster forms a spatially connected component.
Parameters
Expand Down Expand Up @@ -119,7 +130,7 @@ def region_k_means(X, n_clusters, w):


class RegionKMeansHeuristic(BaseSpOptHeuristicSolver):
"""Solve the region-K-means problem, the K-means with the constraint
"""Solve the region-K-means problem with the constraint
that each cluster forms a spatially connected component.
Expand All @@ -138,14 +149,15 @@ class RegionKMeansHeuristic(BaseSpOptHeuristicSolver):
Attributes
----------
labels_ :
...
centroids_ :
...
labels_ : numpy.array
Region IDs for observations
iters_ :
...
centroids_ : numpy.ndarray
Floating point array of centroids in the shape of ``(k, n_features)``
found at the last iteration of ``region_k_means``.
iters : int
The number of iterations for the reassignment phase.
"""

Expand Down