Skip to content

Commit 3710b64

Browse files
committed
Added doc for itml
1 parent 0c37099 commit 3710b64

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

doc/source/algorithms/itml.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
Information Theoretic Metric Learning (ITML)
22
=====================================
3+
ITML minimizes the differential relative entropy between two multivariate Gaussians under constraints on the distance function, which can be formulated into a particular Bregman optimization problem by minimizing the LogDet divergence subject to the linear constraints. This algorithm can handle wide variety of constraints and can optionally incorporate a prior on the distance function. Unlike some existing method, ITML is fast and scalable since no eigenvalue computation or semi-definite programming are required.
34

45
Example Code
56
------------------
7+
After loading the iris data, we apply ITML:
8+
::
9+
from metric_learn import ITML
10+
11+
num_constraints = 200
12+
n = self.iris_points.shape[0]
13+
C = ITML.prepare_constraints(self.iris_labels, n, num_constraints)
14+
itml = ITML().fit(self.iris_points, C, verbose=False)
15+
itml.transform()
616

717
References
8-
------------------
18+
------------------
19+
`Information-theoretic Metric Learning <http://machinelearning.wustl.edu/mlpapers/paper_files/icml2007_DavisKJSD07.pdf>`_ Davis, Jason V., et al.

doc/source/algorithms/lmnn.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Example Code
88
We use iris data here for all the examples:
99
::
1010
from sklearn.datasets import load_iris
11+
import numpy as np
1112

1213
iris_data = load_iris()
1314
self.iris_points = iris_data['data']
@@ -16,12 +17,13 @@ We use iris data here for all the examples:
1617

1718
In this package, we have two different implementations of LMNN. Here we try both implementations in a for loop:
1819
::
20+
from metric_learn import LMNN
21+
from metric_learn.lmnn import python_LMNN
22+
1923
for LMNN_cls in set((LMNN, python_LMNN)):
2024
lmnn = LMNN_cls(k=k, learn_rate=1e-6)
2125
lmnn.fit(self.iris_points, self.iris_labels, verbose=False)
22-
23-
csep = class_separation(lmnn.transform(), self.iris_labels)
24-
self.assertLess(csep, 0.25)
26+
lmnn.transform()
2527

2628
References
2729
------------------

0 commit comments

Comments
 (0)