Skip to content

Commit 710379e

Browse files
RobinVogelperimosocordiae
authored andcommitted
[DOC] solves several small raised issues (#266)
* solves #258, #261, and #256
1 parent 65a98cc commit 710379e

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

doc/getting_started.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ Quick start
2929
This example loads the iris dataset, and evaluates a k-nearest neighbors
3030
algorithm on an embedding space learned with `NCA`.
3131

32-
>>> from metric_learn import NCA
33-
>>> from sklearn.datasets import load_iris
34-
>>> from sklearn.model_selection import cross_val_score
35-
>>> from sklearn.pipeline import make_pipeline
36-
>>>
37-
>>> X, y = load_iris(return_X_y=True)
38-
>>> clf = make_pipeline(NCA(), KNeighborsClassifier())
39-
>>> cross_val_score(clf, X, y)
32+
::
33+
34+
from metric_learn import NCA
35+
from sklearn.datasets import load_iris
36+
from sklearn.model_selection import cross_val_score
37+
from sklearn.pipeline import make_pipeline
38+
from sklearn.neighbors import KNeighborsClassifier
39+
40+
X, y = load_iris(return_X_y=True)
41+
clf = make_pipeline(NCA(), KNeighborsClassifier())
42+
cross_val_score(clf, X, y)

doc/supervised.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ Supervised versions of weakly-supervised algorithms
374374
Each :ref:`weakly-supervised algorithm <weakly_supervised_section>`
375375
has a supervised version of the form `*_Supervised` where similarity tuples are
376376
randomly generated from the labels information and passed to the underlying
377-
algorithm.
377+
algorithm.
378+
379+
.. warning::
380+
Supervised versions of weakly-supervised algorithms interpret label -1
381+
(or any negative label) as a point with unknown label.
382+
Those points are discarded in the learning process.
378383

379384
For pairs learners (see :ref:`learning_on_pairs`), pairs (tuple of two points
380385
from the dataset), and pair labels (`int` indicating whether the two points

metric_learn/itml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class ITML_Supervised(_BaseITML, TransformerMixin):
273273
be removed in 0.6.0.
274274
num_constraints: int, optional
275275
number of constraints to generate
276+
(`20 * num_classes**2` constraints by default)
276277
bounds : Not used
277278
.. deprecated:: 0.5.0
278279
`bounds` was deprecated in version 0.5.0 and will

metric_learn/lsml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class LSML_Supervised(_BaseLSML, TransformerMixin):
276276
be removed in 0.6.0.
277277
num_constraints: int, optional
278278
number of constraints to generate
279+
(`20 * num_classes**2` constraints by default)
279280
weights : (m,) array of floats, optional
280281
scale factor for each constraint
281282
verbose : bool, optional

metric_learn/mmc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ class MMC_Supervised(_BaseMMC, TransformerMixin):
498498
be removed in 0.6.0.
499499
num_constraints: int, optional
500500
number of constraints to generate
501+
(`20 * num_classes**2` constraints by default)
501502
init : None, string or numpy array, optional (default=None)
502503
Initialization of the Mahalanobis matrix. Possible options are
503504
'identity', 'covariance', 'random', and a numpy array of

metric_learn/sdml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class SDML_Supervised(_BaseSDML, TransformerMixin):
302302
be removed in 0.6.0.
303303
num_constraints : int, optional (default=None)
304304
number of constraints to generate
305+
(`20 * num_classes**2` constraints by default)
305306
verbose : bool, optional (default=False)
306307
if True, prints information while learning
307308
preprocessor : array-like, shape=(n_samples, n_features) or callable

0 commit comments

Comments
 (0)