cblearn.metrics.query_accuracy#

cblearn.metrics.query_accuracy(true_response, pred_response)[source]#

Fraction of violated triplet constraints.

For all triplets (i, j, k), count R * (||O(j) - O(i)|| - ||O(k) - O(i)||) > 0 and divide by the number of triplets.

Parameters:
  • true_response (ndarray | COO | spmatrix) – Triplet constraints either in array or sparse matrix format

  • pred_response (ndarray | COO | spmatrix) – Either object coordinates, shape (n_objects, n_features), or predicted triplet response.

Returns:

Number between 0 and 1, indicating the fraction of triplet constraints which are violated.

Return type:

float