@@ -160,9 +160,9 @@ Also, as explained before, our metric learner has learned a distance between
160160points. You can use this distance in two main ways:
161161
162162- You can either return the distance between pairs of points using the
163- `score_pairs ` function:
163+ `pair_distance ` function:
164164
165- >>> mmc.score_pairs ([[[3.5 , 3.6 , 5.2 ], [5.6 , 2.4 , 6.7 ]],
165+ >>> mmc.pair_distance ([[[3.5 , 3.6 , 5.2 ], [5.6 , 2.4 , 6.7 ]],
166166... [[1.2 , 4.2 , 7.7 ], [2.1 , 6.4 , 0.9 ]]])
167167array([7.27607365, 0.88853014])
168168
@@ -175,6 +175,18 @@ array([7.27607365, 0.88853014])
175175>>> metric_fun([3.5 , 3.6 , 5.2 ], [5.6 , 2.4 , 6.7 ])
1761767.276073646278203
177177
178+ - Alternatively, you can use `pair_score ` to return the **score ** between
179+ pairs of points (the larger the score, the more similar the pair).
180+ For Mahalanobis learners, it is equal to the opposite of the distance.
181+
182+ >>> score = mmc.pair_score([[[3.5 , 3.6 ], [5.6 , 2.4 ]], [[1.2 , 4.2 ], [2.1 , 6.4 ]], [[3.3 , 7.8 ], [10.9 , 0.1 ]]])
183+ >>> score
184+ array([-0.49627072, -3.65287282, -6.06079877])
185+
186+ This is useful because `pair_score ` matches the **score ** semantic of
187+ scikit-learn's `Classification metrics
188+ <https://scikit-learn.org/stable/modules/model_evaluation.html#classification-metrics> `_.
189+
178190.. note ::
179191
180192 If the metric learner that you use learns a :ref: `Mahalanobis distance
@@ -187,8 +199,6 @@ array([[ 0.58603894, -5.69883982, -1.66614919],
187199 [-5.69883982, 55.41743549, 16.20219519],
188200 [-1.66614919, 16.20219519, 4.73697721]])
189201
190- .. TODO: remove the "like it is the case etc..." if it's not the case anymore
191-
192202.. _sklearn_compat_ws :
193203
194204Prediction and scoring
@@ -344,8 +354,8 @@ returns the `sklearn.metrics.roc_auc_score` (which is threshold-independent).
344354
345355.. note ::
346356 See :ref: `fit_ws ` for more details on metric learners functions that are
347- not specific to learning on pairs, like `transform `, `score_pairs `,
348- `get_metric ` and `get_mahalanobis_matrix `.
357+ not specific to learning on pairs, like `transform `, `pair_distance `,
358+ `pair_score `, ` get_metric ` and `get_mahalanobis_matrix `.
349359
350360Algorithms
351361----------
@@ -691,8 +701,8 @@ of triplets that have the right predicted ordering.
691701
692702.. note ::
693703 See :ref: `fit_ws ` for more details on metric learners functions that are
694- not specific to learning on pairs, like `transform `, `score_pairs `,
695- `get_metric ` and `get_mahalanobis_matrix `.
704+ not specific to learning on pairs, like `transform `, `pair_distance `,
705+ `pair_score `, ` get_metric ` and `get_mahalanobis_matrix `.
696706
697707
698708
@@ -859,8 +869,8 @@ of quadruplets have the right predicted ordering.
859869
860870.. note ::
861871 See :ref: `fit_ws ` for more details on metric learners functions that are
862- not specific to learning on pairs, like `transform `, `score_pairs `,
863- `get_metric ` and `get_mahalanobis_matrix `.
872+ not specific to learning on pairs, like `transform `, `pair_distance `,
873+ `pair_score `, ` get_metric ` and `get_mahalanobis_matrix `.
864874
865875
866876
0 commit comments