Skip to content

Commit b9c0974

Browse files
author
mvargas33
committed
Merge remote-tracking branch 'upstream/master' into feat-rename-vars
2 parents 9db49b0 + 8571f97 commit b9c0974

File tree

7 files changed

+87
-206
lines changed

7 files changed

+87
-206
lines changed

.github/workflows/main.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the master branch
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
jobs:
12+
13+
# Checks compatibility with an old version of sklearn (0.20.3)
14+
compatibility:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest]
19+
python-version: ['3.6', '3.7', '3.8']
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Run Tests with skggm + scikit-learn 0.20.3
27+
env:
28+
SKGGM_VERSION: a0ed406586c4364ea3297a658f415e13b5cbdaf8
29+
run: |
30+
sudo apt-get install liblapack-dev
31+
pip install --upgrade pip pytest
32+
pip install wheel cython numpy scipy codecov pytest-cov
33+
pip install scikit-learn==0.20.3
34+
pip install git+https://github.com/skggm/skggm.git@${SKGGM_VERSION}
35+
pytest test --cov
36+
bash <(curl -s https://codecov.io/bash)
37+
38+
# Run normal testing with the latests versions of all dependencies
39+
build:
40+
runs-on: ${{ matrix.os }}
41+
strategy:
42+
matrix:
43+
os: [ubuntu-latest]
44+
python-version: ['3.6', '3.7', '3.8', '3.9']
45+
steps:
46+
- uses: actions/checkout@v2
47+
- name: Set up Python
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
- name: Run Tests without skggm
52+
run: |
53+
sudo apt-get install liblapack-dev
54+
pip install --upgrade pip pytest
55+
pip install wheel cython numpy scipy codecov pytest-cov scikit-learn
56+
pytest test --cov
57+
bash <(curl -s https://codecov.io/bash)
58+
- name: Run Tests with skggm
59+
env:
60+
SKGGM_VERSION: a0ed406586c4364ea3297a658f415e13b5cbdaf8
61+
run: |
62+
pip install git+https://github.com/skggm/skggm.git@${SKGGM_VERSION}
63+
pytest test --cov
64+
bash <(curl -s https://codecov.io/bash)
65+
- name: Syntax checking with flake8
66+
run: |
67+
pip install flake8
68+
flake8 --extend-ignore=E111,E114 --show-source;

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
|Travis-CI Build Status| |License| |PyPI version| |Code coverage|
1+
|GitHub Actions Build Status| |License| |PyPI version| |Code coverage|
22

33
metric-learn: Metric Learning in Python
44
=======================================
@@ -67,8 +67,8 @@ Bibtex entry::
6767

6868
.. _sphinx documentation: http://contrib.scikit-learn.org/metric-learn/
6969

70-
.. |Travis-CI Build Status| image:: https://api.travis-ci.org/scikit-learn-contrib/metric-learn.svg?branch=master
71-
:target: https://travis-ci.org/scikit-learn-contrib/metric-learn
70+
.. |GitHub Actions Build Status| image:: https://github.com/scikit-learn-contrib/metric-learn/workflows/CI/badge.svg
71+
:target: https://github.com/scikit-learn-contrib/metric-learn/actions?query=event%3Apush+branch%3Amaster
7272
.. |License| image:: http://img.shields.io/:license-mit-blue.svg?style=flat
7373
:target: http://badges.mit-license.org
7474
.. |PyPI version| image:: https://badge.fury.io/py/metric-learn.svg

build_tools/travis/flake8_diff.sh

Lines changed: 0 additions & 132 deletions
This file was deleted.

doc/supervised.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ same class are not imposed to be close.
292292
lfda = LFDA(k=2, dim=2)
293293
lfda.fit(X, Y)
294294

295+
.. note::
296+
LDFA suffers from a problem called “sign indeterminacy”, which means the sign of the ``components`` and the output from transform depend on a random state. This is directly related to the calculation of eigenvectors in the algorithm. The same input ran in different times might lead to different transforms, but both valid.
297+
298+
To work around this, fit instances of this class to data once, then keep the instance around to do transformations.
299+
295300
.. topic:: References:
296301

297302
.. [1] Sugiyama. `Dimensionality Reduction of Multimodal Labeled Data by Local

test/metric_learn_test.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,17 @@ def test_singular_returns_pseudo_inverse(self):
7979
class TestSCML(object):
8080
@pytest.mark.parametrize('basis', ('lda', 'triplet_diffs'))
8181
def test_iris(self, basis):
82+
"""
83+
SCML applied to Iris dataset should give better results when
84+
computing class separation.
85+
"""
8286
X, y = load_iris(return_X_y=True)
87+
before = class_separation(X, y)
8388
scml = SCML_Supervised(basis=basis, n_basis=85, k_genuine=7, k_impostor=5,
8489
random_state=42)
8590
scml.fit(X, y)
86-
csep = class_separation(scml.transform(X), y)
87-
assert csep < 0.24
91+
after = class_separation(scml.transform(X), y)
92+
assert before > after + 0.03 # It's better by a margin of 0.03
8893

8994
def test_big_n_features(self):
9095
X, y = make_classification(n_samples=100, n_classes=3, n_features=60,
@@ -929,7 +934,7 @@ def test_singleton_class(self):
929934
X = X[[ind_0[0], ind_1[0], ind_2[0]]]
930935
y = y[[ind_0[0], ind_1[0], ind_2[0]]]
931936

932-
A = make_spd_matrix(X.shape[1], X.shape[1])
937+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
933938
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
934939
nca.fit(X, y)
935940
assert_array_equal(nca.components_, A)
@@ -940,7 +945,7 @@ def test_one_class(self):
940945
X = self.iris_points[self.iris_labels == 0]
941946
y = self.iris_labels[self.iris_labels == 0]
942947

943-
A = make_spd_matrix(X.shape[1], X.shape[1])
948+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
944949
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
945950
nca.fit(X, y)
946951
assert_array_equal(nca.components_, A)

test/test_mahalanobis_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ def test_init_mahalanobis(estimator, build_dataset):
503503
model.fit(input_data, labels)
504504

505505
# Initialize with a random spd matrix
506-
init = make_spd_matrix(X.shape[1], random_state=rng)
506+
init = make_spd_matrix(n_dim=X.shape[1], random_state=rng)
507507
model.set_params(**{param: init})
508508
model.fit(input_data, labels)
509509

510510
# init.shape[1] must match X.shape[1]
511-
init = make_spd_matrix(X.shape[1] + 1, X.shape[1] + 1)
511+
init = make_spd_matrix(n_dim=X.shape[1] + 1, random_state=rng)
512512
model.set_params(**{param: init})
513513
msg = ('The input dimensionality {} of the given '
514514
'mahalanobis matrix `{}` must match the '

0 commit comments

Comments
 (0)