diff --git a/README.rst b/README.rst index d62d32c0..38c088aa 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Metric Learning algorithms in Python. **Dependencies** -- Python 2.6+ +- Python 2.7+, 3.4+ - numpy, scipy, scikit-learn - (for running the examples only: matplotlib) diff --git a/doc/index.rst b/doc/index.rst index b9c0c209..df4ed8a6 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -17,6 +17,7 @@ metric learning algorithms. :caption: Algorithms :maxdepth: 1 + metric_learn.covariance metric_learn.lmnn metric_learn.itml metric_learn.sdml @@ -51,7 +52,7 @@ Alternately, download the source repository and run: **Dependencies** -- Python 2.6+ +- Python 2.7+, 3.4+ - numpy, scipy, scikit-learn - (for running the examples only: matplotlib) diff --git a/doc/metric_learn.covariance.rst b/doc/metric_learn.covariance.rst new file mode 100644 index 00000000..d24229a3 --- /dev/null +++ b/doc/metric_learn.covariance.rst @@ -0,0 +1,21 @@ +Covariance metric (baseline method) +=================================== + +.. automodule:: metric_learn.covariance + :members: + :undoc-members: + :inherited-members: + :show-inheritance: + +Example Code +------------ + +:: + + from metric_learn import Covariance + from sklearn.datasets import load_iris + + iris_data = load_iris() + + cov = Covariance() + x = cov.fit_transform(iris_data['data']) diff --git a/doc/metric_learn.itml.rst b/doc/metric_learn.itml.rst index 6f4cf740..d6fb2221 100644 --- a/doc/metric_learn.itml.rst +++ b/doc/metric_learn.itml.rst @@ -12,19 +12,15 @@ Example Code :: - import numpy as np - from metric_learn import ITML + from metric_learn import ITML_Supervised from sklearn.datasets import load_iris iris_data = load_iris() X = iris_data['data'] Y = iris_data['target'] - itml = ITML() - - num_constraints = 200 - C = ITML.prepare_constraints(Y, X.shape[0], num_constraints) - itml.fit(X, C, verbose=False) + itml = ITML_Supervised(num_constraints=200) + itml.fit(X, Y) References ---------- diff --git a/doc/metric_learn.lsml.rst b/doc/metric_learn.lsml.rst index 4409e562..12be71b8 100644 --- a/doc/metric_learn.lsml.rst +++ b/doc/metric_learn.lsml.rst @@ -12,17 +12,15 @@ Example Code :: - import numpy as np - from metric_learn import LSML + from metric_learn import LSML_Supervised from sklearn.datasets import load_iris iris_data = load_iris() X = iris_data['data'] Y = iris_data['target'] - lsml = LSML() - C = LSML.prepare_constraints(Y, 200) - isml.fit(X, C, verbose=False) + lsml = LSML_Supervised(num_constraints=200) + isml.fit(X, Y) References ---------- diff --git a/doc/metric_learn.rca.rst b/doc/metric_learn.rca.rst index a73c6e7c..2430cd82 100644 --- a/doc/metric_learn.rca.rst +++ b/doc/metric_learn.rca.rst @@ -12,17 +12,15 @@ Example Code :: - import numpy as np - from metric_learn import RCA + from metric_learn import RCA_Supervised from sklearn.datasets import load_iris iris_data = load_iris() X = iris_data['data'] Y = iris_data['target'] - rca = RCA() - C = RCA.prepare_constraints(Y, num_chunks=30, chunk_size=2) - rca.fit(X, C) + rca = RCA_Supervised(num_chunks=30, chunk_size=2) + rca.fit(X, Y) References ------------------ diff --git a/doc/metric_learn.sdml.rst b/doc/metric_learn.sdml.rst index de48fec5..83570483 100644 --- a/doc/metric_learn.sdml.rst +++ b/doc/metric_learn.sdml.rst @@ -12,17 +12,15 @@ Example Code :: - import numpy as np - from metric_learn import SDML + from metric_learn import SDML_Supervised from sklearn.datasets import load_iris iris_data = load_iris() X = iris_data['data'] Y = iris_data['target'] - sdml = SDML() - W = SDML.prepare_constraints(Y, X.shape[0], 1500) - sdml.fit(X, W) + sdml = SDML_Supervised(num_constraints=200) + sdml.fit(X, Y) References ------------------ diff --git a/metric_learn/sdml.py b/metric_learn/sdml.py index c861d10d..aba1b9be 100644 --- a/metric_learn/sdml.py +++ b/metric_learn/sdml.py @@ -55,7 +55,8 @@ def fit(self, X, W): """ X: data matrix, (n x d) each row corresponds to a single instance - W: connectivity graph, (n x n). +1 for positive pairs, -1 for negative. + W: connectivity graph, (n x n) + +1 for positive pairs, -1 for negative. """ self._prepare_inputs(X, W) P = pinvh(self.M) + self.params['balance_param'] * self.loss_matrix diff --git a/setup.py b/setup.py index 9696b78f..2031754a 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from setuptools import setup -version = "0.2.1" +version = "0.3.0" setup(name='metric-learn', version=version, description='Python implementations of metric learning algorithms', @@ -26,12 +26,12 @@ 'six' ], extras_require=dict( - docs=['sphinx', 'numpydoc'], + docs=['sphinx', 'shinx_rtd_theme', 'numpydoc'], demo=['matplotlib'], ), test_suite='test', keywords=[ - 'Metric Learning', + 'Metric Learning', 'Large Margin Nearest Neighbor', 'Information Theoretic Metric Learning', 'Sparse Determinant Metric Learning',