Skip to content

Commit 14bda7c

Browse files
authored
DOC add metrics documentation in user guide (#375)
1 parent db780e4 commit 14bda7c

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

doc/metrics.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. _metrics:
2+
3+
=======
4+
Metrics
5+
=======
6+
7+
.. currentmodule:: imblearn.metrics
8+
9+
Currently, scikit-learn only offers the
10+
``sklearn.metrics.balanced_accuracy_score`` (in 0.20) as metric to deal with
11+
imbalanced datasets. The module :mod:`imblearn.metrics` offers a couple of
12+
other metrics which are used in the literature to evaluate the quality of
13+
classifiers.
14+
15+
.. _sensitivity_specificity:
16+
17+
Sensitivity and specificity metrics
18+
-----------------------------------
19+
20+
Sensitivity and specificity are metrics which are well known in medical
21+
imaging. Sensitivity (also called true positive rate or recall) is the
22+
proportion of the positive samples which is well classified while specificity
23+
(also called true negative rate) is the proportion of the negative samples
24+
which are well classified. Therefore, depending of the field of application,
25+
either the sensitivity/specificity or the precision/recall pair of metrics are
26+
used.
27+
28+
Currently, only the `precision and recall metrics
29+
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html>`_
30+
are implemented in scikit-learn. :func:`sensitivity_specificity_support`,
31+
:func:`sensitivity_score`, and :func:`specificity_score` add the possibility to
32+
use those metrics.
33+
34+
.. _imbalanced_metrics:
35+
36+
Additional metrics specific to imbalanced datasets
37+
--------------------------------------------------
38+
39+
The :func:`geometric_mean_score` is the root of the product of class-wise
40+
sensitivity. This measure tries to maximize the accuracy on each of the classes
41+
while keeping these accuracies balanced.
42+
43+
The :func:`make_index_balanced_accuracy` can wrap any metric and give more
44+
importance to a specific class using the parameter ``alpha``.

doc/user_guide.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ User Guide
1414
under_sampling.rst
1515
combine.rst
1616
ensemble.rst
17+
metrics.rst
1718
Dataset loading utilities <datasets/index.rst>
1819
developers_utils.rst

doc/whats_new/v0.0.4.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Enhancement
1212
- Add a documentation node to create a balanced random forest from a balanced
1313
bagging classifier. :issue:`372` by :user:`Guillaume Lemaitre <glemaitre>`.
1414

15+
- Document the metrics to evaluate models on imbalanced dataset. :issue:`367`
16+
by :user:`Guillaume Lemaitre <glemaitre>`.
17+
1518
Bug fixes
1619
.........
1720

imblearn/metrics/classification.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def sensitivity_specificity_support(y_true,
6060
returns the average sensitivity and specificity if ``average``
6161
is one of ``'weighted'``.
6262
63+
Read more in the :ref:`User Guide <sensitivity_specificity>`.
64+
6365
Parameters
6466
----------
6567
y_true : ndarray, shape (n_samples, )
@@ -277,6 +279,8 @@ def sensitivity_score(y_true,
277279
278280
The best value is 1 and the worst value is 0.
279281
282+
Read more in the :ref:`User Guide <sensitivity_specificity>`.
283+
280284
Parameters
281285
----------
282286
y_true : ndarray, shape (n_samples, )
@@ -376,6 +380,8 @@ def specificity_score(y_true,
376380
377381
The best value is 1 and the worst value is 0.
378382
383+
Read more in the :ref:`User Guide <sensitivity_specificity>`.
384+
379385
Parameters
380386
----------
381387
y_true : ndarray, shape (n_samples, )
@@ -486,6 +492,8 @@ class is unrecognized by the classifier, G-mean resolves to zero. To
486492
unrecognized classes can be "corrected" to be a user specified value
487493
(instead of zero). This option works only if ``average == 'multiclass'``.
488494
495+
Read more in the :ref:`User Guide <imbalanced_metrics>`.
496+
489497
Parameters
490498
----------
491499
y_true : ndarray, shape (n_samples, )
@@ -649,6 +657,8 @@ def make_index_balanced_accuracy(alpha=0.1, squared=True):
649657
balanced accuracy. ``y_score`` cannot be used since the dominance
650658
cannot be computed.
651659
660+
Read more in the :ref:`User Guide <imbalanced_metrics>`.
661+
652662
Parameters
653663
----------
654664
alpha : float, optional (default=0.1)

0 commit comments

Comments
 (0)