mapclassify.HeadTailBreaks¶
-
class
mapclassify.
HeadTailBreaks
(y)[source]¶ Head/tail Breaks Map Classification for Heavy-tailed Distributions
- Parameters
- yarray
(n,1), values to classify
Notes
Head/tail Breaks is a relatively new classification method developed for data with a heavy-tailed distribution.
Implementation based on contributions by Alessandra Sozzi <alessandra.sozzi@gmail.com>.
For theoretical details see [Jia13].
Examples
>>> import numpy as np >>> import mapclassify as mc >>> np.random.seed(10) >>> cal = mc.load_example() >>> htb = mc.HeadTailBreaks(cal) >>> htb.k 3 >>> htb.counts array([50, 7, 1]) >>> htb.bins array([ 125.92810345, 811.26 , 4111.45 ]) >>> np.random.seed(123456) >>> x = np.random.lognormal(3, 1, 1000) >>> htb = mc.HeadTailBreaks(x) >>> htb.bins array([ 32.26204423, 72.50205622, 128.07150107, 190.2899093 , 264.82847377, 457.88157946, 576.76046949]) >>> htb.counts array([695, 209, 62, 22, 10, 1, 1])
- Attributes
- ybarray
(n,1), bin ids for observations,
- binsarray
(k,1), the upper bounds of each class
- kint
the number of classes
- countsarray
(k,1), the number of observations falling in each class
Methods
__init__
(self, y)Initialize self.
find_bin
(self, x)Sort input or inputs according to the current bin estimate
get_adcm
(self)Absolute deviation around class median (ADCM).
get_fmt
(self)get_gadf
(self)Goodness of absolute deviation of fit
get_legend_classes
(self[, fmt])Format the strings for the classes on the legend
get_tss
(self)Total sum of squares around class means
make
(\*args, \*\*kwargs)Configure and create a classifier that will consume data and produce classifications, given the configuration options specified by this function.
plot
(self, gdf[, border_color, …])Plot Mapclassiifer NOTE: Requires matplotlib, and implicitly requires geopandas dataframe as input.
set_fmt
(self, fmt)table
(self)update
(self[, y, inplace])Add data or change classification parameters.
Attributes
fmt