mapclassify.StdMean

class mapclassify.StdMean(y, multiples=[-2, -1, 1, 2], anchor=False)[source]

Standard Deviation and Mean Map Classification.

Parameters:
ynumpy.array

\((n,1)\), values to classify

multiplesnumpy.array (default [-2, -1, 1, 2])

The multiples of the standard deviation to add/subtract from the sample mean to define the bins.

anchorbool (default False)

Anchor upper bound of one class to the sample mean.

Notes

If anchor is True, one of the intervals will have its closed upper bound equal to the mean of y. Intermediate intervals will have widths equal to the standard deviation of y. The first interval will be closed on the minimum value of y, and the last interval will be closed on the maximum of y. The first and last intervals may have widths different from the intermediate intervals.

Examples

>>> import mapclassify
>>> cal = mapclassify.load_example()
>>> st = mapclassify.StdMean(cal)
>>> st.k
5
>>> st.bins
array([-967.36235382, -420.71712519,  672.57333208, 1219.21856072,
       4111.45      ])
>>> st.counts.tolist()
[0, 0, 56, 1, 1]
>>> st3 = mapclassify.StdMean(cal, multiples = [-3, -1.5, 1.5, 3])
>>> st3.bins
array([-1514.00758246,  -694.03973951,   945.8959464 ,  1765.86378936,
        4111.45      ])
>>> st3.counts.tolist()
[0, 0, 57, 0, 1]
>>> stda = mapclassify.StdMean(cal, anchor=True)
>>> stda.k
9
>>> stda.bins
array([ 125.92810345,  672.57333208, 1219.21856072, 1765.86378936,
       2312.50901799, 2859.15424663, 3405.79947527, 3952.4447039 ,
       4111.45      ])
>>> float(cal.mean()), float(cal.std()), float(cal.min()), float(cal.max())
(125.92810344827588, 546.6452286365233, 0.13, 4111.45)
Attributes:
ybnumpy.array

\((n,1)\), bin IDs for observations.

binsnumpy.array

\((k,1)\), the upper bounds of each class.

kint

The number of classes.

countsnumpy.array

\((k,1)\), the number of observations falling in each class.

__init__(y, multiples=[-2, -1, 1, 2], anchor=False)[source]

Methods

__init__(y[, multiples, anchor])

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.

set_fmt(fmt)

table()

update([y, inplace])

Add data or change classification parameters.

Attributes

fmt

update(y=None, inplace=False, **kwargs)[source]

Add data or change classification parameters.

Parameters:
ynumpy.array (default None)

\((n,1)\), array of data to classify.

inplacebool (default False)

Whether to conduct the update in place or to return a copy estimated from the additional specifications.

**kwargsdict

Additional parameters that are passed to the __init__ function of the class. For documentation, check the class constructor.