Connection
Base URL, credentials and a reachable server.
Reject length mismatches and unknown labels, keeping zero counts for classes never observed.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
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