cblearn.preprocessing.triplets_from_oddoneout#

cblearn.preprocessing.triplets_from_oddoneout(X, y=None)[source]#

Calculates triplets from odd-one-out queries.

The odd-one-out query consists of k objects, of which one is most dissimilar to all others.

Note

For this transformation, we are assuming that the objects respect the triangle inequality. This might not always be a given and is not checked by this function.

Parameters:
  • X (ndarray) – Array of odd-one-out queries (n_query, n_choices)

  • y (ndarray | None) – Optional list of indices, that indicate the odd choice per query. If omitted, the first entry is assumed to be the odd object.

Returns:

Array of triplet queries (n_query * (n_choices - 2) * (n_choices - 1), 3)

Return type:

triplets