metrics.zeroOneLoss

zeroOneLoss(y_true: `object`, y_pred: `object`, __namedParameters: `object`)

Zero-one classification loss.

If normalize is true, return the fraction of misclassifications (float), else it returns the number of misclassifications (int). The best performance is 0.

Usage

import { zeroOneLoss } from 'machinelearn/metrics';

const loss_zero_one_result = zeroOneLoss(
  [1, 2, 3, 4],
  [2, 2, 3, 5]
);
console.log(loss_zero_one_result); // 0.5

Defined in metrics/classification.ts:140

Parameters:

ParamTypeDefaultDescription
y_trueanynullGround truth (correct) labels.
y_predanynullPredicted labels, as returned by a classifier.
options.normalizebooleantrueIf False, return the number of misclassifications. Otherwise, return the fraction of misclassifications.

Returns:

number