Skip to content

Commit

Permalink
Merge pull request #214 from sjsrey/region-docs
Browse files Browse the repository at this point in the history
Region docs
  • Loading branch information
jGaboardi authored Feb 5, 2022
2 parents 863f40b + 0b289ba commit 56c57ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
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

0 comments on commit 56c57ea

Please sign in to comment.