metrics.confusion_matrix
▸ confusion_matrix(y_true: `object`, y_pred: `object`, labels: `object`)
Usage
import { confusion_matrix } from 'machinelearn/metrics';
const matrix1 = confusion_matrix([1, 2, 3], [1, 2, 3]);
console.log(matrix1); // [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
const matrix2 = confusion_matrix(
['cat', 'ant', 'cat', 'cat', 'ant', 'bird'],
['ant', 'ant', 'cat', 'cat', 'ant', 'cat']
);
console.log(matrix2); // [ [ 1, 2, 0 ], [ 2, 0, 0 ], [ 0, 1, 0 ] ]
Defined in metrics/classification.ts:189
Parameters:
Param | Type | Default | Description |
---|---|---|---|
y_true | string[] or number[] | null | Ground truth (correct) target values. |
y_pred | string[] or number[] | null | Estimated targets as returned by a classifier. |
options.labels | any[] | null |
Returns:
number[]