From 438d15bcb3cd993acf319fbc23d9dfee3630829a Mon Sep 17 00:00:00 2001 From: RobinVogel Date: Wed, 20 Nov 2019 11:32:10 +0100 Subject: [PATCH 1/5] solves #258 --- doc/getting_started.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/getting_started.rst b/doc/getting_started.rst index 5a671d86..5ce4242a 100644 --- a/doc/getting_started.rst +++ b/doc/getting_started.rst @@ -29,11 +29,14 @@ Quick start This example loads the iris dataset, and evaluates a k-nearest neighbors algorithm on an embedding space learned with `NCA`. ->>> from metric_learn import NCA ->>> from sklearn.datasets import load_iris ->>> from sklearn.model_selection import cross_val_score ->>> from sklearn.pipeline import make_pipeline ->>> ->>> X, y = load_iris(return_X_y=True) ->>> clf = make_pipeline(NCA(), KNeighborsClassifier()) ->>> cross_val_score(clf, X, y) +:: + + from metric_learn import NCA + from sklearn.datasets import load_iris + from sklearn.model_selection import cross_val_score + from sklearn.pipeline import make_pipeline + from sklearn.neighbors import KNeighborsClassifier + + X, y = load_iris(return_X_y=True) + clf = make_pipeline(NCA(), KNeighborsClassifier()) + cross_val_score(clf, X, y) From 77753cff112e7774afee75ca1baf05875c1d2487 Mon Sep 17 00:00:00 2001 From: RobinVogel Date: Wed, 20 Nov 2019 11:44:03 +0100 Subject: [PATCH 2/5] solves #261 --- doc/supervised.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/supervised.rst b/doc/supervised.rst index 3c941b20..70a25755 100644 --- a/doc/supervised.rst +++ b/doc/supervised.rst @@ -374,7 +374,12 @@ Supervised versions of weakly-supervised algorithms Each :ref:`weakly-supervised algorithm ` has a supervised version of the form `*_Supervised` where similarity tuples are randomly generated from the labels information and passed to the underlying -algorithm. +algorithm. + +.. warning:: + Supervised versions of weakly-supervised algortihms interpret label -1 + (or any negative label) as a point with unknown label. + Those points are discarded in the learning process. For pairs learners (see :ref:`learning_on_pairs`), pairs (tuple of two points from the dataset), and pair labels (`int` indicating whether the two points From 4270107ee13ed7dbbb4b0114949bc9122a00a270 Mon Sep 17 00:00:00 2001 From: RobinVogel Date: Wed, 20 Nov 2019 14:26:21 +0100 Subject: [PATCH 3/5] Solves issue #256 --- metric_learn/itml.py | 1 + metric_learn/lsml.py | 1 + metric_learn/mmc.py | 1 + metric_learn/sdml.py | 1 + 4 files changed, 4 insertions(+) diff --git a/metric_learn/itml.py b/metric_learn/itml.py index 1f3f90ee..990bdd38 100644 --- a/metric_learn/itml.py +++ b/metric_learn/itml.py @@ -273,6 +273,7 @@ class ITML_Supervised(_BaseITML, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate + (`20 * num_classes**2` constraints if not specified) bounds : Not used .. deprecated:: 0.5.0 `bounds` was deprecated in version 0.5.0 and will diff --git a/metric_learn/lsml.py b/metric_learn/lsml.py index dfb12720..05db623e 100644 --- a/metric_learn/lsml.py +++ b/metric_learn/lsml.py @@ -276,6 +276,7 @@ class LSML_Supervised(_BaseLSML, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate + (`20 * num_classes**2` constraints if not specified) weights : (m,) array of floats, optional scale factor for each constraint verbose : bool, optional diff --git a/metric_learn/mmc.py b/metric_learn/mmc.py index 0999e417..28b54726 100644 --- a/metric_learn/mmc.py +++ b/metric_learn/mmc.py @@ -498,6 +498,7 @@ class MMC_Supervised(_BaseMMC, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate + (`20 * num_classes**2` constraints if not specified) init : None, string or numpy array, optional (default=None) Initialization of the Mahalanobis matrix. Possible options are 'identity', 'covariance', 'random', and a numpy array of diff --git a/metric_learn/sdml.py b/metric_learn/sdml.py index 2cdaa164..52921dd9 100644 --- a/metric_learn/sdml.py +++ b/metric_learn/sdml.py @@ -302,6 +302,7 @@ class SDML_Supervised(_BaseSDML, TransformerMixin): be removed in 0.6.0. num_constraints : int, optional (default=None) number of constraints to generate + (`20 * num_classes**2` constraints if not specified) verbose : bool, optional (default=False) if True, prints information while learning preprocessor : array-like, shape=(n_samples, n_features) or callable From b22af58381c1f513491a7dae73f77a3943169b0b Mon Sep 17 00:00:00 2001 From: RobinVogel Date: Wed, 20 Nov 2019 15:07:05 +0100 Subject: [PATCH 4/5] maj --- metric_learn/itml.py | 2 +- metric_learn/lsml.py | 2 +- metric_learn/mmc.py | 2 +- metric_learn/sdml.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/metric_learn/itml.py b/metric_learn/itml.py index 990bdd38..5202c9e1 100644 --- a/metric_learn/itml.py +++ b/metric_learn/itml.py @@ -273,7 +273,7 @@ class ITML_Supervised(_BaseITML, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate - (`20 * num_classes**2` constraints if not specified) + (`20 * num_classes**2` constraints by default) bounds : Not used .. deprecated:: 0.5.0 `bounds` was deprecated in version 0.5.0 and will diff --git a/metric_learn/lsml.py b/metric_learn/lsml.py index 05db623e..b9df3825 100644 --- a/metric_learn/lsml.py +++ b/metric_learn/lsml.py @@ -276,7 +276,7 @@ class LSML_Supervised(_BaseLSML, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate - (`20 * num_classes**2` constraints if not specified) + (`20 * num_classes**2` constraints by default) weights : (m,) array of floats, optional scale factor for each constraint verbose : bool, optional diff --git a/metric_learn/mmc.py b/metric_learn/mmc.py index 28b54726..622beb25 100644 --- a/metric_learn/mmc.py +++ b/metric_learn/mmc.py @@ -498,7 +498,7 @@ class MMC_Supervised(_BaseMMC, TransformerMixin): be removed in 0.6.0. num_constraints: int, optional number of constraints to generate - (`20 * num_classes**2` constraints if not specified) + (`20 * num_classes**2` constraints by default) init : None, string or numpy array, optional (default=None) Initialization of the Mahalanobis matrix. Possible options are 'identity', 'covariance', 'random', and a numpy array of diff --git a/metric_learn/sdml.py b/metric_learn/sdml.py index 52921dd9..21fadd74 100644 --- a/metric_learn/sdml.py +++ b/metric_learn/sdml.py @@ -302,7 +302,7 @@ class SDML_Supervised(_BaseSDML, TransformerMixin): be removed in 0.6.0. num_constraints : int, optional (default=None) number of constraints to generate - (`20 * num_classes**2` constraints if not specified) + (`20 * num_classes**2` constraints by default) verbose : bool, optional (default=False) if True, prints information while learning preprocessor : array-like, shape=(n_samples, n_features) or callable From 8cae29aa5f0289a1b119c57bbc57fba228207203 Mon Sep 17 00:00:00 2001 From: RobinVogel Date: Thu, 21 Nov 2019 10:03:50 +0100 Subject: [PATCH 5/5] typo --- doc/supervised.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/supervised.rst b/doc/supervised.rst index 70a25755..f221ba4a 100644 --- a/doc/supervised.rst +++ b/doc/supervised.rst @@ -377,7 +377,7 @@ randomly generated from the labels information and passed to the underlying algorithm. .. warning:: - Supervised versions of weakly-supervised algortihms interpret label -1 + Supervised versions of weakly-supervised algorithms interpret label -1 (or any negative label) as a point with unknown label. Those points are discarded in the learning process.