cblearn.preprocessing.triplets_from_multiselect#

cblearn.preprocessing.triplets_from_multiselect(X, select, is_ranked)[source]#

Calculate triplets from n-select or n-rank queries.

The n-select query consists of \(k>2\) object indices. The first index indicates the pivot object. The selected objects should be more similar to the pivot, than the other objects. The selected objects themself can be ordered in similarity to the pivot (is_ranked=True).

Triplets are a special case of n-select queries, with a single other object.

Parameters:
  • X (ndarray) – n-select or n-rank query as array (n_query, n_choices)

  • select (ndarray | int) – Integer of first n selected columns or a 2d array (n_query, n_select) of column indices in X (0..n_choices).

  • is_ranked (bool) – If true, assumes that the selected objects are ordered by their similarity.

Returns:

Array of triplet queries

(n_query * (2 * (n_choices - n_select - 1) + int(is_ranked)), 3)

Return type:

triplets