scikit-learn/scikit-learn — pull request #3959 by imkevinyang (2014-12-11 11:53:20+00:00)
Title: Fix usability issue in metrics.classification_report.

Fix usability issue in metrics.classification_report.
In following codes, 'class 0' and 'class 1' will be printed, while 'class 0' and 'class 2' are expected.
```python
y_true = [0, 0, 2, 0, 0]
y_pred = [0, 2, 2, 0, 0]
target_names = ['class 0', 'class 1', 'class 2']
print(metrics.classification_report(y_true, y_pred, target_names=target_names))

== console ==
precision recall f1-score support

class 0 1.00 0.75 0.86 4
class 1 0.50 1.00 0.67 1

avg / total 0.90 0.80 0.82 5
```

In real world, we don't know which label will be included in y_true or y_pred, since those may come from random subset using KFold. So include all the label names in 'target_names' is safer and more intuitive.