Skip to content

Commit 5433e72

Browse files
authored
Merge pull request #4249 from ajdapretnar/clustering-test
Updated tests to sklearn=0.22.0
2 parents b3c5fdf + 25cbd01 commit 5433e72

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

Orange/evaluation/clustering.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,18 @@ class ClusteringScore(Score):
3535
# pylint: disable=arguments-differ
3636
def from_predicted(self, results, score_function):
3737
# Clustering scores from labels
38-
# This warning filter can be removed in scikit 0.22
39-
with warnings.catch_warnings():
40-
warnings.filterwarnings(
41-
"ignore", "The behavior of AMI will change in version 0\\.22.*")
42-
if self.considers_actual:
43-
return np.fromiter(
44-
(score_function(results.actual.flatten(),
45-
predicted.flatten())
46-
for predicted in results.predicted),
47-
dtype=np.float64, count=len(results.predicted))
48-
# Clustering scores from data only
49-
else:
50-
return np.fromiter(
51-
(score_function(results.data.X, predicted.flatten())
52-
for predicted in results.predicted),
53-
dtype=np.float64, count=len(results.predicted))
38+
if self.considers_actual:
39+
return np.fromiter(
40+
(score_function(results.actual.flatten(),
41+
predicted.flatten())
42+
for predicted in results.predicted),
43+
dtype=np.float64, count=len(results.predicted))
44+
# Clustering scores from data only
45+
else:
46+
return np.fromiter(
47+
(score_function(results.data.X, predicted.flatten())
48+
for predicted in results.predicted),
49+
dtype=np.float64, count=len(results.predicted))
5450

5551

5652
class Silhouette(ClusteringScore):

Orange/tests/test_evaluation_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_kmeans(self):
3535
KMeans(n_clusters=5)])
3636
expected = [0.68081362, 0.55259194, 0.48851755]
3737
np.testing.assert_almost_equal(Silhouette(cr), expected, decimal=2)
38-
expected = [0.51936073, 0.74837231, 0.59178896]
38+
expected = [0.65383807, 0.75511917, 0.68721092]
3939
np.testing.assert_almost_equal(AdjustedMutualInfoScore(cr),
4040
expected, decimal=2)
4141
self.assertIsNone(cr.models)

Orange/widgets/data/tests/test_owcorrelations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def test_n_clusters(self):
357357

358358
def test_get_clusters_of_attributes(self):
359359
clusters = self.heuristic.get_clusters_of_attributes()
360-
self.assertListEqual([[0], [1, 2, 3, 4, 5, 6, 7], [8]],
360+
self.assertListEqual([[1, 2, 3, 4, 5, 6, 7], [8], [0]],
361361
[c.instances for c in clusters])
362362

363363
def test_get_states(self):

requirements-core.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pip>=9.0
22
numpy>=1.16.0
33
scipy>=0.16.1
4-
scikit-learn>=0.20.0
4+
scikit-learn>=0.22.0
55
bottleneck>=1.0.0
66
# Reading Excel files
77
xlrd>=0.9.2

0 commit comments

Comments
 (0)