GitHub
deepbox/metrics

Classification Metrics

Classification scores, threshold curves, reports, and confusion-matrix utilities.
Evaluation
accuracy
export declare function accuracy(yTrue: Tensor, yPred: Tensor): number;

Calculates the accuracy classification score.

averagePrecisionScore
export declare function averagePrecisionScore(yTrue: Tensor, yScore: Tensor): number;

Average precision score.

balancedAccuracyScore
export declare function balancedAccuracyScore(yTrue: Tensor, yPred: Tensor): number;

Balanced accuracy score.

classificationReport
export declare function classificationReport(yTrue: Tensor, yPred: Tensor): string;

Generates a text classification report showing main classification metrics.

cohenKappaScore
export declare function cohenKappaScore(yTrue: Tensor, yPred: Tensor): number;

Cohen's kappa score.

confusionMatrix
export declare function confusionMatrix(yTrue: Tensor, yPred: Tensor): Tensor;

Computes the confusion matrix to evaluate classification accuracy.

f1Score
export declare function f1Score(yTrue: Tensor, yPred: Tensor, average: { average: "binary" | "micro" | "macro" | "weighted"; }): number;

f1Score is exported by deepbox/metrics.

fbetaScore
export declare function fbetaScore(yTrue: Tensor, yPred: Tensor, beta: number, average: null): number[];

fbetaScore is exported by deepbox/metrics.

hammingLoss
export declare function hammingLoss(yTrue: Tensor, yPred: Tensor): number;

Hamming loss.

jaccardScore
export declare function jaccardScore(yTrue: Tensor, yPred: Tensor): number;

Jaccard similarity score (Intersection over Union).

logLoss
export declare function logLoss(yTrue: Tensor, yPred: Tensor): number;

Log loss (logistic loss, cross-entropy loss).

matthewsCorrcoef
export declare function matthewsCorrcoef(yTrue: Tensor, yPred: Tensor): number;

Matthews correlation coefficient (MCC).

precision
export declare function precision(yTrue: Tensor, yPred: Tensor, average: null): number[];

precision is exported by deepbox/metrics.

precisionRecallCurve
export declare function precisionRecallCurve(yTrue: Tensor, yScore: Tensor): [Tensor, Tensor, Tensor];

Precision-Recall curve.

recall
export declare function recall(yTrue: Tensor, yPred: Tensor, average: null): number[];

recall is exported by deepbox/metrics.

rocAucScore
export declare function rocAucScore(yTrue: Tensor, yScore: Tensor): number;

Area Under ROC Curve (AUC-ROC).

rocCurve
export declare function rocCurve(yTrue: Tensor, yScore: Tensor): [Tensor, Tensor, Tensor];

ROC curve data.

metrics-classification.ts
import {  accuracy,  classificationReport,  confusionMatrix,  f1Score,  rocAucScore,} from "deepbox/metrics";import { tensor } from "deepbox/ndarray";const yTrue = tensor([0, 1, 1, 0, 1]);const yPred = tensor([0, 1, 0, 0, 1]);const yScore = tensor([0.1, 0.8, 0.4, 0.2, 0.9]);console.log(accuracy(yTrue, yPred));console.log(f1Score(yTrue, yPred));console.log(rocAucScore(yTrue, yScore));console.log(confusionMatrix(yTrue, yPred).toString());console.log(classificationReport(yTrue, yPred));