seldonian.models.objectives.confusion_matrix

confusion_matrix(model, theta, X, Y, l_i, l_k, **kwargs)

Get the mean probability of predicting class label l_k if the true class label was l_i. This is the C[l_i,l_k] element of the confusion matrix, C. Let:

i = number of datapoints j = number of features (including bias term, if provied) k = number of classes

Parameters:
  • model – SeldonianModel instance

  • theta (array of shape (j,k)) – The parameter weights

  • X (array of shape (i,j)) – The features

  • Y (array of shape (i,k)) – The labels

  • l_i (int) – The index in the confusion matrix corresponding to the true label (row)

  • l_k (int) – The index in the confusion matrix corresponding to the predicted label (column)

Returns:

C[l_i,l_k]

Return type:

float