Skip to content
This repository
Browse code

Pool Adjacent Violators now does a max_iter number of iteration

  • Loading branch information...
commit 0ee486f2e35d2aa8965c8daf965f0aef661256ad 1 parent 3a55480
Varoquaux NelleV authored GaelVaroquaux committed

Showing 1 changed file with 13 additions and 2 deletions. Show diff stats Hide diff stats

  1. +13 2 sklearn/manifold/mds.py
15 sklearn/manifold/mds.py
@@ -15,7 +15,8 @@
15 15 from ..externals.joblib import delayed
16 16
17 17
18   -def pool_adjacent_violators(distances, similarities):
  18 +def pool_adjacent_violators(distances, similarities, max_iter=300,
  19 + verbose=0):
19 20 """
20 21 Pool adjancent violators
21 22
@@ -29,6 +30,12 @@ def pool_adjacent_violators(distances, similarities):
29 30 similarities: ndarray, shape (n, 1)
30 31 array on which to fit
31 32
  33 + max_iter: int, optional, default:300
  34 + Set the maximum number of iteration
  35 +
  36 + verbose: int, optional, default: 0
  37 + set the level of verbosity
  38 +
32 39 Returns
33 40 -------
34 41 distances: ndarray, shape (n, 1)
@@ -41,7 +48,7 @@ def pool_adjacent_violators(distances, similarities):
41 48
42 49 block = []
43 50 sort = True
44   - while sort:
  51 + for it in range(max_iter):
45 52 sort = False
46 53 blocks = new_blocks[:]
47 54 new_blocks = []
@@ -66,6 +73,10 @@ def pool_adjacent_violators(distances, similarities):
66 73 new_blocks.append(block[0])
67 74 else:
68 75 new_blocks.append(len(similarities) - 1)
  76 + if not sort:
  77 + if verbose:
  78 + print "Breaking at iteration %d" % it
  79 + break
69 80
70 81 return distances
71 82

0 comments on commit 0ee486f

Please sign in to comment.
Something went wrong with that request. Please try again.