MMatrixTern
Product

Product features · Classification confusion matrices

01

Reject length mismatches and unknown labels, keeping zero counts for classes never observed.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Classification confusion matrices

● ● ●MatrixTern●
A concrete starting point · Classification confusion matrices ×
def confusion(expected, predicted, labels):
    if len(expected) != len(predicted) or len(set(labels)) != len(labels):
        raise ValueError("labels or lengths")
    index = {label: i for i, label in enumerate(labels)}
    matrix = [[0] * len(labels) for _ in labels]
    for actual, guess in zip(expected, predicted):
        if actual not in index or guess not in index:
            raise ValueError("unknown label")
        matrix[index[actual]][index[guess]] += 1
    return matrix
✳Build a confusion matrix from expected and predicted labels.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗