cblearn.datasets.make_random_triplets#

cblearn.datasets.make_random_triplets(embedding, result_format, size=1.0, random_state=None, repeat=True, monotonic=False, make_all=10000, **kwargs)[source]#

Make random triplets with answers for the provided embedding or distances.

>>> triplets, answers = make_random_triplets(np.random.rand(12, 2), size=1000, result_format='list-boolean')
>>> answers.shape, np.unique(answers).tolist()
((1000,), [False,  True])
>>> triplets.shape, np.unique(triplets).tolist()
((1000, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
Parameters:
  • embedding (ndarray) – Object coordinates (n_objects, n_components) or distance matrix (n_objects, n_objects).

  • result_format (str) – Result format

  • size (int | float) – Either absolute or relative number of triplets to generate.

  • repeat (bool) – Sample triplet indices with repetitions

  • monotonic (bool) – Sample triplets (j, i, k), such that j < i < k.

  • make_all (int) – Choose from all triplets instead of iterative sampling, if the difference between all triplets to the requested number is smaller than this value.

  • random_state (None | int | RandomState) – Seed for triplet sampling and noisy answers

  • kwargs – Additional arguments passed to cblearn.datasets.noisy_triplet_answers()

Returns:

The triplets and answers, based on format. See cblearn.utils.check_triplets().

Return type:

ndarray | COO | spmatrix