Skip to content

Commit 903f174

Browse files
author
William de Vazelhes
committed
Update docstring for new api
1 parent a7e4807 commit 903f174

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

metric_learn/itml.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ def fit(self, pairs, y, bounds=None):
8686
8787
Parameters
8888
----------
89-
X : (n x d) data matrix
90-
each row corresponds to a single instance
91-
constraints : 4-tuple of arrays
92-
(a,b,c,d) indices into X, with (a,b) specifying positive and (c,d)
93-
negative pairs
89+
pairs: array-like, shape=(n_constraints, 2, n_features)
90+
Array of pairs. Each row corresponds to two points.
91+
y: array-like, of shape (n_constraints,)
92+
Labels of constraints. Should be 0 for dissimilar pair, 1 for similar.
9493
bounds : list (pos,neg) pairs, optional
9594
bounds on similarity, s.t. d(X[a],X[b]) < pos and d(X[c],X[d]) > neg
95+
96+
Returns
97+
-------
98+
self : object
99+
Returns the instance.
96100
"""
97101
pairs, y = self._process_pairs(pairs, y, bounds)
98102
gamma = self.gamma

metric_learn/lsml.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,18 @@ def fit(self, quadruplets, weights=None):
6565
6666
Parameters
6767
----------
68-
X : (n x d) data matrix
69-
each row corresponds to a single instance
70-
constraints : 4-tuple of arrays
71-
(a,b,c,d) indices into X, such that d(X[a],X[b]) < d(X[c],X[d])
72-
weights : (m,) array of floats, optional
68+
quadruplets : array-like, shape=(n_constraints, 4, n_features)
69+
Each row corresponds to 4 points. In order to supervise the
70+
algorithm in the right way, we should have the four samples ordered
71+
in a way such that: d(pairs[i, 0],X[i, 1]) < d(X[i, 2], X[i, 3])
72+
for all 0 <= i < n_constraints.
73+
weights : (n_constraints,) array of floats, optional
7374
scale factor for each constraint
75+
76+
Returns
77+
-------
78+
self : object
79+
Returns the instance.
7480
"""
7581
self._prepare_quadruplets(quadruplets, weights)
7682
step_sizes = np.logspace(-10, 0, 10)

metric_learn/mmc.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ def fit(self, pairs, y):
6464
6565
Parameters
6666
----------
67-
X : (n x d) data matrix
68-
each row corresponds to a single instance
69-
constraints : 4-tuple of arrays
70-
(a,b,c,d) indices into X, with (a,b) specifying similar and (c,d)
71-
dissimilar pairs
67+
pairs: array-like, shape=(n_constraints, 2, n_features)
68+
Array of pairs. Each row corresponds to two points.
69+
y: array-like, of shape (n_constraints,)
70+
Labels of constraints. Should be 0 for dissimilar pair, 1 for similar.
71+
72+
Returns
73+
-------
74+
self : object
75+
Returns the instance.
7276
"""
7377
pairs, y = self._process_pairs(pairs, y)
7478
if self.diagonal:

metric_learn/sdml.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def fit(self, pairs, y):
6262
6363
Parameters
6464
----------
65-
X : array-like, shape (n, d)
66-
data matrix, where each row corresponds to a single instance
67-
W : array-like, shape (n, n)
68-
connectivity graph, with +1 for positive pairs and -1 for negative
65+
pairs: array-like, shape=(n_constraints, 2, n_features)
66+
Array of pairs. Each row corresponds to two points.
67+
y: array-like, of shape (n_constraints,)
68+
Labels of constraints. Should be 0 for dissimilar pair, 1 for similar.
6969
7070
Returns
7171
-------

0 commit comments

Comments
 (0)