mapclassify.UserDefined

class mapclassify.UserDefined(y, bins)[source]

User Specified Binning

Parameters
yarray

(n,1), values to classify

binsarray

(k,1), upper bounds of classes (have to be monotically increasing)

Notes

If upper bound of user bins does not exceed max(y) we append an additional bin.

Examples

>>> import mapclassify as mc
>>> cal = mc.load_example()
>>> bins = [20, max(cal)]
>>> bins
[20, 4111.45]
>>> ud = mc.UserDefined(cal, bins)
>>> ud.bins
array([  20.  , 4111.45])
>>> ud.counts
array([37, 21])
>>> bins = [20, 30]
>>> ud = mc.UserDefined(cal, bins)
>>> ud.bins
array([  20.  ,   30.  , 4111.45])
>>> ud.counts
array([37,  4, 17])
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

__init__(self, y, bins)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, y, bins)

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

plot(self, gdf, border_color='lightgrey', border_width=0.1, title=None, legend=False, cmap='YlGnBu', axis_on=True, legend_kwds={'loc': 'lower right', 'fmt': '{:.2f}'}, file_name=None, dpi=600, ax=None)[source]

Plot Mapclassiifer NOTE: Requires matplotlib, and implicitly requires geopandas dataframe as input.

gdfgeopandas geodataframe

Contains the geometry column for the choropleth map

border_colorstring, optional

matplotlib color string to use for polygon border (Default: lightgrey)

border_widthfloat, optional

width of polygon boarder (Default: 0.10)

titlestring, optional

Title of map (Default: None)

cmapstring, optional

matplotlib color string for color map to fill polygons (Default: YlGn)

axis_onboolean, optional

Show coordinate axes (default True) (Default: True)

legend_kwdsdict, optional

options for ax.legend() (Default: {“loc”: “lower right”, ‘fmt’:FMT})

file_namestring, optional

Name of file to save figure to. (Default: None)

dpiint, optional

Dots per inch for saved figure (Default: 600)

axmatplotlib axis, optional

axis on which to plot the choropleth. (Default: None, so plots on the current figure)

f,axtuple

matplotlib figure, axis on which the plot is made.

Examples

>>> import libpysal as lp
>>> import geopandas
>>> import mapclassify
>>> gdf = geopandas.read_file(lp.examples.get_path("columbus.shp"))
>>> q5 = mapclassify.Quantiles(gdf.CRIME)
>>> q5.plot(gdf)  
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.