seldonian.parse_tree.zhat_funcs.vector_confusion_matrix

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

Get the 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 model 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] for each observation

Return type:

numpy ndarray(float between 0 and 1)