Skip to content

Commit aebd47f

Browse files
author
William de Vazelhes
committed
MAINT clearer formulation to make the prior appear
1 parent 02cc937 commit aebd47f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

metric_learn/sdml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ def _fit(self, pairs, y):
5858
# set up prior M
5959
if self.use_cov:
6060
X = np.vstack({tuple(row) for row in pairs.reshape(-1, pairs.shape[2])})
61-
self.M_ = np.cov(X, rowvar = False)
61+
self.M_ = pinvh(np.cov(X, rowvar = False))
6262
else:
6363
self.M_ = np.identity(pairs.shape[2])
6464
diff = pairs[:, 0] - pairs[:, 1]
6565
loss_matrix = (diff.T * y).dot(diff)
66-
emp_cov = self.M_ + self.balance_param * loss_matrix
66+
emp_cov = pinvh(self.M_) + self.balance_param * loss_matrix
6767
_, self.M_ = graph_lasso(emp_cov, self.sparsity_param, verbose=self.verbose)
6868

6969
self.transformer_ = transformer_from_metric(self.M_)

0 commit comments

Comments
 (0)