def _compute()

in metrics/matthews_correlation/matthews_correlation.py [0:0]


    def _compute(self, predictions, references, sample_weight=None, average=None):
        if self.config_name == "multilabel":
            references = np.array(references)
            predictions = np.array(predictions)
            if not (references.ndim == 2 and predictions.ndim == 2):
                raise ValueError("For multi-label inputs, both references and predictions should be 2-dimensional")
            matthews_corr = [
                matthews_corrcoef(predictions[:, i], references[:, i], sample_weight=sample_weight)
                for i in range(references.shape[1])
            ]
            if average == "macro":
                matthews_corr = np.mean(matthews_corr)
            elif average is not None:
                raise ValueError("Invalid `average`: expected `macro`, or None ")
        else:
            matthews_corr = float(matthews_corrcoef(references, predictions, sample_weight=sample_weight))
        return {"matthews_correlation": matthews_corr}