Skip to content

Commit 944bb3e

Browse files
author
William de Vazelhes
committed
Merge remote-tracking branch 'origin/master' into fix/remove_num_labeled_parameter
# Conflicts: # metric_learn/itml.py # metric_learn/lsml.py # metric_learn/mmc.py
2 parents 8727c44 + ac0e230 commit 944bb3e

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# General information about the project.
1717
project = u'metric-learn'
18-
copyright = u'2015-2017, CJ Carey and Yuan Tang'
18+
copyright = u'2015-2018, CJ Carey and Yuan Tang'
1919
author = u'CJ Carey and Yuan Tang'
2020
version = '0.4.0'
2121
release = '0.4.0'

metric_learn/itml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def fit(self, X, y, random_state=np.random):
197197
warnings.warn('"num_labeled" parameter is not used.'
198198
' It has been deprecated in version 0.4 and will be'
199199
'removed in 0.5', DeprecationWarning)
200-
X, y = check_X_y(X, y)
200+
X, y = check_X_y(X, y, ensure_min_samples=2)
201201
num_constraints = self.num_constraints
202202
if num_constraints is None:
203203
num_classes = len(np.unique(y))

metric_learn/lmnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def transformer(self):
5252
class python_LMNN(_base_LMNN):
5353

5454
def _process_inputs(self, X, labels):
55-
self.X_ = check_array(X, dtype=float)
55+
self.X_ = check_array(X, dtype=float, ensure_min_samples=2)
5656
num_pts, num_dims = self.X_.shape
5757
unique_labels, self.label_inds_ = np.unique(labels, return_inverse=True)
5858
if len(self.label_inds_) != num_pts:

metric_learn/lsml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def fit(self, X, y, random_state=np.random):
184184
warnings.warn('"num_labeled" parameter is not used.'
185185
' It has been deprecated in version 0.4 and will be'
186186
'removed in 0.5', DeprecationWarning)
187-
X, y = check_X_y(X, y)
187+
X, y = check_X_y(X, y, ensure_min_samples=2)
188188
num_constraints = self.num_constraints
189189
if num_constraints is None:
190190
num_classes = len(np.unique(y))

metric_learn/mmc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def fit(self, X, y, random_state=np.random):
439439
warnings.warn('"num_labeled" parameter is not used.'
440440
' It has been deprecated in version 0.4 and will be'
441441
'removed in 0.5', DeprecationWarning)
442-
X, y = check_X_y(X, y)
442+
X, y = check_X_y(X, y, ensure_min_samples=2)
443443
num_constraints = self.num_constraints
444444
if num_constraints is None:
445445
num_classes = len(np.unique(y))

setup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
# -*- coding: utf-8 -*-
33
from setuptools import setup
44
import os
5+
import io
56

67
version = {}
7-
with open(os.path.join('metric_learn', '_version.py')) as fp:
8+
with io.open(os.path.join('metric_learn', '_version.py')) as fp:
89
exec(fp.read(), version)
910

11+
# Get the long description from README.md
12+
with io.open('README.rst', encoding='utf-8') as f:
13+
long_description = f.read()
14+
1015
setup(name='metric-learn',
1116
version=version['__version__'],
1217
description='Python implementations of metric learning algorithms',
18+
long_description=long_description,
1319
author=['CJ Carey', 'Yuan Tang'],
1420
author_email='ccarey@cs.umass.edu',
15-
url='http://github.com/all-umass/metric-learn',
21+
url='http://github.com/metric-learn/metric-learn',
1622
license='MIT',
1723
classifiers=[
1824
'Development Status :: 4 - Beta',
@@ -40,5 +46,9 @@
4046
'Information Theoretic Metric Learning',
4147
'Sparse Determinant Metric Learning',
4248
'Least Squares Metric Learning',
43-
'Neighborhood Components Analysis'
49+
'Neighborhood Components Analysis',
50+
'Local Fisher Discriminant Analysis',
51+
'Relative Components Analysis',
52+
'Mahalanobis Metric for Clustering',
53+
'Metric Learning for Kernel Regression'
4454
])

test/metric_learn_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_iris(self):
4444

4545
csep = class_separation(cov.transform(), self.iris_labels)
4646
# deterministic result
47-
self.assertAlmostEqual(csep, 0.73068122)
47+
self.assertAlmostEqual(csep, 0.72981476)
4848

4949

5050
class TestLSML(MetricTestCase):
@@ -166,7 +166,7 @@ def test_iris(self):
166166
nca = NCA(max_iter=(100000//n), num_dims=2, tol=1e-9)
167167
nca.fit(self.iris_points, self.iris_labels)
168168
csep = class_separation(nca.transform(), self.iris_labels)
169-
self.assertLess(csep, 0.15)
169+
self.assertLess(csep, 0.20)
170170

171171
def test_finite_differences(self):
172172
"""Test gradient of loss function
@@ -352,16 +352,17 @@ def test_iris(self):
352352
# Full metric
353353
mmc = MMC(convergence_threshold=0.01)
354354
mmc.fit(self.iris_points, [a,b,c,d])
355-
expected = [[+0.00046504, +0.00083371, -0.00111959, -0.00165265],
356-
[+0.00083371, +0.00149466, -0.00200719, -0.00296284],
357-
[-0.00111959, -0.00200719, +0.00269546, +0.00397881],
358-
[-0.00165265, -0.00296284, +0.00397881, +0.00587320]]
355+
expected = [[ 0.000514, 0.000868, -0.001195, -0.001703],
356+
[ 0.000868, 0.001468, -0.002021, -0.002879],
357+
[-0.001195, -0.002021, 0.002782, 0.003964],
358+
[-0.001703, -0.002879, 0.003964, 0.005648]]
359359
assert_array_almost_equal(expected, mmc.metric(), decimal=6)
360360

361361
# Diagonal metric
362362
mmc = MMC(diagonal=True)
363363
mmc.fit(self.iris_points, [a,b,c,d])
364-
expected = [0, 0, 1.21045968, 1.22552608]
364+
expected = [0, 0, 1.210220, 1.228596]
365+
365366
assert_array_almost_equal(np.diag(expected), mmc.metric(), decimal=6)
366367

367368
# Supervised Full

0 commit comments

Comments
 (0)