mapclassify.gadf¶
- mapclassify.gadf(y, method='Quantiles', maxk=15, pct=0.8)[source]¶
Evaluate the Goodness of Absolute Deviation Fit (GADF) of a classifier and find the minimum value of \(k\) for which
gadf > pct
.- Parameters:
- y
numpy.array
\((n, 1)\), values to be classified.
- method
str
(default
‘Quantiles’) The classification method in:
{'Quantiles', 'Fisher_Jenks', 'Maximum_Breaks', 'Natrual_Breaks'}
.- maxk
int
(default
15) Maximum value of \(k\) to evaluate.
- pct
float
(default
0.8) The percentage of GADF to exceed.
- y
- Returns:
See also
Notes
The GADF is defined as:
\[GADF = 1 - \sum_c \sum_{i \in c} |y_i - y_{c,med}| / \sum_i |y_i - y_{med}|\]where \(y_{med}\) is the global median and \(y_{c,med}\) is the median for class \(c\).
Examples
>>> import mapclassify >>> cal = mapclassify.load_example() >>> qgadf = mapclassify.classifiers.gadf(cal) >>> qgadf[0] 15
>>> float(qgadf[-1]) 0.3740257590909283
Quantiles fail to exceed 0.80 before 15 classes. If we lower the bar to 0.2 we see quintiles as a result
>>> qgadf2 = mapclassify.classifiers.gadf(cal, pct = 0.2) >>> qgadf2[0] 5
>>> float(qgadf2[-1]) 0.21710231966462412