Skip to contents

Label-vector form of morie_mcc_counts, matching the calling convention of sklearn.metrics.matthews_corrcoef and of morie.fn.mcc's matthews_corrcoef. Returns a bare numeric so the result compares and orders like a number.

Usage

morie_matthews_corrcoef(y_true, y_pred)

Arguments

y_true

Vector of observed labels.

y_pred

Vector of predicted labels, same length as y_true.

Value

A single numeric in [-1, 1].

Details

Binary labels only. The two levels are taken from the values actually present rather than assumed to be 0/1, so c(-1, 1) and character labels work; the second level in sorted order is treated as the positive class. Counts are derived and handed to morie_mcc_counts, so both entry points share one implementation of the formula.

References

Matthews BW (1975). Comparison of the predicted and observed secondary structure of T4 phage lysozyme. Biochimica et Biophysica Acta, 405(2), 442-451.

See also

Examples

morie_matthews_corrcoef(c(0, 0, 1, 1), c(0, 0, 1, 1))
#> [1] 1
morie_matthews_corrcoef(c(0, 0, 1, 1), c(1, 1, 0, 0))
#> [1] -1