Skip to content

[DOC] solves several small raised issues #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 6 additions & 1 deletion doc/supervised.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,12 @@ Supervised versions of weakly-supervised algorithms
Each :ref:`weakly-supervised algorithm <weakly_supervised_section>`
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 algorithms 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
Expand Down
1 change: 1 addition & 0 deletions metric_learn/itml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 by default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to use double-backticks here to prevent the docs from interpreting this as a link target. Can you build the HTML docs with these changes to verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it locally and I see it works as expected, also there is a itml_supervised.fit(X, y, bounds=...) that does not uses double backticks in the code a few lines below.

Should I make a pull request for the documentation that I generated as well ?
The commits that update the documentation look a bit heavy for minor modifications and include some system-specific results.

bounds : Not used
.. deprecated:: 0.5.0
`bounds` was deprecated in version 0.5.0 and will
Expand Down
1 change: 1 addition & 0 deletions metric_learn/lsml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 by default)
weights : (m,) array of floats, optional
scale factor for each constraint
verbose : bool, optional
Expand Down
1 change: 1 addition & 0 deletions metric_learn/mmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down
1 change: 1 addition & 0 deletions metric_learn/sdml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 by default)
verbose : bool, optional (default=False)
if True, prints information while learning
preprocessor : array-like, shape=(n_samples, n_features) or callable
Expand Down