mapclassify.BoxPlot

class mapclassify.BoxPlot(y, hinge=1.5)[source]

BoxPlot Map Classification

Parameters
yarray

attribute to classify

hingefloat

multiplier for IQR

Notes

The bins are set as follows:

bins[0] = q[0]-hinge*IQR
bins[1] = q[0]
bins[2] = q[1]
bins[3] = q[2]
bins[4] = q[2]+hinge*IQR
bins[5] = inf  (see Notes)

where q is an array of the first three quartiles of y and IQR=q[2]-q[0]

If q[2]+hinge*IQR > max(y) there will only be 5 classes and no high outliers, otherwise, there will be 6 classes and at least one high outlier.

Examples

>>> import mapclassify as mc
>>> cal = mc.load_example()
>>> bp = mc.BoxPlot(cal)
>>> bp.bins
array([-5.287625e+01,  2.567500e+00,  9.365000e+00,  3.953000e+01,
        9.497375e+01,  4.111450e+03])
>>> bp.counts
array([ 0, 15, 14, 14,  6,  9])
>>> bp.high_outlier_ids
array([ 0,  6, 18, 29, 33, 36, 37, 40, 42])
>>> cal[bp.high_outlier_ids].values
array([ 329.92,  181.27,  370.5 ,  722.85,  192.05,  110.74, 4111.45,
        317.11,  264.93])
>>> bx = mc.BoxPlot(np.arange(100))
>>> bx.bins
array([-49.5 ,  24.75,  49.5 ,  74.25, 148.5 ])
Attributes
ybarray

(n,1), bin ids for observations

binsarray

(n,1), the upper bounds of each class (monotonic)

kint

the number of classes

countsarray

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

low_outlier_idsarray

indices of observations that are low outliers

high_outlier_idsarray

indices of observations that are high outliers

__init__(self, y, hinge=1.5)[source]
Parameters
yarray (n,1)

attribute to classify

hingefloat

multiple of inter-quartile range (default=1.5)

Methods

__init__(self, y[, hinge])

Parameters

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

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

Add data or change classification parameters.

Parameters
yarray

(n,1) array of data to classify

inplacebool

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

Additional parameters provided in **kwargs are passed to the init
function of the class. For documentation, check the class constructor.