mapclassify.HeadTailBreaks¶
- class mapclassify.HeadTailBreaks(y)[source]¶
Head/tail Breaks Map Classification for Heavy-tailed Distributions.
- Parameters:
- y
numpy.array
\((n,1)\), values to classify.
- y
- Attributes:
- yb
numpy.array
\((n,1)\), bin IDs for observations.
- bins
numpy.array
\((k,1)\), the upper bounds of each class.
- k
int
The number of classes.
- counts
numpy.array
\((k,1)\), the number of observations falling in each class.
- yb
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 mapclassify >>> import numpy >>> numpy.random.seed(10) >>> cal = mapclassify.load_example() >>> htb = mapclassify.HeadTailBreaks(cal) >>> htb.k 3
>>> htb.counts.tolist() [50, 7, 1]
>>> htb.bins array([ 125.92810345, 811.26 , 4111.45 ])
>>> numpy.random.seed(123456) >>> x = numpy.random.lognormal(3, 1, 1000) >>> htb = mapclassify.HeadTailBreaks(x) >>> htb.bins array([ 32.26204423, 72.50205622, 128.07150107, 190.2899093 , 264.82847377, 457.88157946, 576.76046949])
>>> htb.counts.tolist() [695, 209, 62, 22, 10, 1, 1]
Methods
__init__
(y)find_bin
(x)Sort input or inputs according to the current bin estimate.
get_adcm
()Absolute deviation around class median (ADCM).
get_fmt
()get_gadf
()Goodness of absolute deviation of fit.
get_legend_classes
([fmt])Format the strings for the classes on the legend.
get_tss
()Returns sum of squares over all 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
(gdf[, border_color, border_width, ...])Plot a mapclassifier object.
plot_histogram
([color, linecolor, ...])Plot histogram of y with bin values superimposed
set_fmt
(fmt)table
()update
([y, inplace])Add data or change classification parameters.
Attributes
fmt