|
| 1 | +Introduction |
| 2 | +===================================== |
| 3 | + |
| 4 | +|Travis-CI Build Status| |License| |
| 5 | + |
| 6 | +Metric Learning algorithms in Python. |
| 7 | + |
| 8 | +**Algorithms** |
| 9 | + |
| 10 | +- Large Margin Nearest Neighbor (LMNN) |
| 11 | +- Information Theoretic Metric Learning (ITML) |
| 12 | +- Sparse Determinant Metric Learning (SDML) |
| 13 | +- Least Squares Metric Learning (LSML) |
| 14 | +- Neighborhood Components Analysis (NCA) |
| 15 | +- Local Fisher Discriminant Analysis (LFDA) |
| 16 | + |
| 17 | +**Dependencies** |
| 18 | + |
| 19 | +- Python 2.6+ |
| 20 | +- numpy, scipy, scikit-learn |
| 21 | +- (for running the examples only: matplotlib) |
| 22 | + |
| 23 | +**Installation/Setup** |
| 24 | + |
| 25 | +Run ``pip install metric-learn`` to download and install from PyPI. |
| 26 | + |
| 27 | +Run ``python setup.py install`` for default installation. |
| 28 | + |
| 29 | +Run ``python setup.py test`` to run all tests. |
| 30 | + |
| 31 | +**Usage** |
| 32 | + |
| 33 | +For full usage examples, see the ``test`` and ``examples`` directories. |
| 34 | + |
| 35 | +Each metric is a subclass of ``BaseMetricLearner``, which provides |
| 36 | +default implementations for the methods ``metric``, ``transformer``, and |
| 37 | +``transform``. Subclasses must provide an implementation for either |
| 38 | +``metric`` or ``transformer``. |
| 39 | + |
| 40 | +For an instance of a metric learner named ``foo`` learning from a set of |
| 41 | +``d``-dimensional points, ``foo.metric()`` returns a ``d`` by ``d`` |
| 42 | +matrix ``M`` such that a distance between vectors ``x`` and ``y`` is |
| 43 | +expressed ``(x-y).dot(M).dot(x-y)``. |
| 44 | + |
| 45 | +In the same scenario, ``foo.transformer()`` returns a ``d`` by ``d`` |
| 46 | +matrix ``L`` such that a vector ``x`` can be represented in the learned |
| 47 | +space as the vector ``L.dot(x)``. |
| 48 | + |
| 49 | +For convenience, the function ``foo.transform(X)`` is provided for |
| 50 | +converting a matrix of points (``X``) into the learned space, in which |
| 51 | +standard Euclidean distance can be used. |
| 52 | + |
| 53 | +**Notes** |
| 54 | + |
| 55 | +If a recent version of the Shogun Python modular (``modshogun``) library |
| 56 | +is available, the LMNN implementation will use the fast C++ version from |
| 57 | +there. The two implementations differ slightly, and the C++ version is |
| 58 | +more complete. |
| 59 | + |
| 60 | +**TODO** |
| 61 | + |
| 62 | +- implement the rest of the methods on `this site`_ |
| 63 | + |
| 64 | +.. _this site: http://www.cs.cmu.edu/~liuy/distlearn.htm |
| 65 | + |
| 66 | +.. |Travis-CI Build Status| image:: https://api.travis-ci.org/all-umass/metric-learn.svg?branch=master |
| 67 | + :target: https://travis-ci.org/all-umass/metric-learn |
| 68 | +.. |License| image:: http://img.shields.io/:license-mit-blue.svg?style=flat |
| 69 | + :target: http://badges.mit-license.org |
0 commit comments