matthews_corr_coeff#

rojak.turbulence.metrics.matthews_corr_coeff(truth: Array | None = None, prediction: Array | None = None, confuse_matrix: NDArray | None = None) float[source]#

Compute the Matthew’s Correlation Coefficient

Parameters:
  • truth (Array | None) – dask array of shape (n_samples,) Ground truth (correct) target values.

  • prediction (Array | None) – dask array of shape (n_samples,) Estimated targets as returned by a classifier.

  • confuse_matrix (NDArray | None) – Numpy array of shape (2, 2) Result from computing the confusion matrix using confusion_matrix(). If this is None, then the result is computed using confusion_matrix() using truth and prediction.

Return type:

float

Returns:

Examples

Example from Wikipedia page on Matthew’s Correlation Coefficient

>>> actual = da.asarray([1,1,1,1,1,1,1,1,0,0,0,0])
>>> pred = da.asarray([0,0,1,1,1,1,1,1,0,0,0,1])
>>> float(matthews_corr_coeff(truth=actual, prediction=pred))
0.478
>>> float(matthews_corr_coeff(confuse_matrix=confusion_matrix(actual, pred)))
0.478