Build a contingency matrix describing the relationship between labels.
Read more in the User Guide.
Ground truth class labels to be used as a reference.
Cluster labels to evaluate.
If a float, that value is added to all values in the contingency matrix. This helps to stop NaN propagation. If None
, nothing is adjusted.
If True
, return a sparse CSR contingency matrix. If eps
is not None
and sparse
is True
will raise ValueError.
Added in version 0.18.
Output dtype. Ignored if eps
is not None
.
Added in version 0.24.
Matrix \(C\) such that \(C_{i, j}\) is the number of samples in true class \(i\) and in predicted class \(j\). If eps is None
, the dtype of this array will be integer unless set otherwise with the dtype
argument. If eps
is given, the dtype will be float. Will be a sklearn.sparse.csr_matrix
if sparse=True
.
Examples
>>> from sklearn.metrics.cluster import contingency_matrix >>> labels_true = [0, 0, 1, 1, 2, 2] >>> labels_pred = [1, 0, 2, 1, 0, 2] >>> contingency_matrix(labels_true, labels_pred) array([[1, 1, 0], [0, 1, 1], [1, 0, 1]])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4