@@ -160,9 +160,9 @@ Also, as explained before, our metric learner has learned a distance between
160
160
points. You can use this distance in two main ways:
161
161
162
162
- You can either return the distance between pairs of points using the
163
- `score_pairs ` function:
163
+ `pair_distance ` function:
164
164
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 ]],
166
166
... [[1.2 , 4.2 , 7.7 ], [2.1 , 6.4 , 0.9 ]]])
167
167
array([7.27607365, 0.88853014])
168
168
@@ -175,6 +175,18 @@ array([7.27607365, 0.88853014])
175
175
>>> metric_fun([3.5 , 3.6 , 5.2 ], [5.6 , 2.4 , 6.7 ])
176
176
7.276073646278203
177
177
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
+
178
190
.. note ::
179
191
180
192
If the metric learner that you use learns a :ref: `Mahalanobis distance
@@ -187,8 +199,6 @@ array([[ 0.58603894, -5.69883982, -1.66614919],
187
199
[-5.69883982, 55.41743549, 16.20219519],
188
200
[-1.66614919, 16.20219519, 4.73697721]])
189
201
190
- .. TODO: remove the "like it is the case etc..." if it's not the case anymore
191
-
192
202
.. _sklearn_compat_ws :
193
203
194
204
Prediction and scoring
@@ -344,8 +354,8 @@ returns the `sklearn.metrics.roc_auc_score` (which is threshold-independent).
344
354
345
355
.. note ::
346
356
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 `.
349
359
350
360
Algorithms
351
361
----------
@@ -691,8 +701,8 @@ of triplets that have the right predicted ordering.
691
701
692
702
.. note ::
693
703
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 `.
696
706
697
707
698
708
@@ -859,8 +869,8 @@ of quadruplets have the right predicted ordering.
859
869
860
870
.. note ::
861
871
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 `.
864
874
865
875
866
876
0 commit comments