Ignore:
Timestamp:
03/10/11 18:09:35 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
50dce81173f748ebbb319370e9e3f76a84756e1c
Message:

Fixed order_leaves calls in cluster(_feature) functions.
Some minor speed improvements in order_leaves (dict lookups tuple de/allocations).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/clustering/hierarchical.py

    r7645 r7732  
    3535    root = orange.HierarchicalClustering(matrix, linkage=linkage, progressCallback=(lambda value, obj=None: progressCallback(value*100.0/(2 if order else 1))) if progressCallback else None) 
    3636    if order: 
    37         orderLeaves(root, matrix, progressCallback=(lambda value: progressCallback(50.0 + value/2)) if progressCallback else None) 
     37        order_leaves(root, matrix, progressCallback=(lambda value: progressCallback(50.0 + value/2)) if progressCallback else None) 
    3838    return root 
    3939 
     
    4646    root = orange.HierarchicalClustering(matrix, linkage=linkage, progressCallback=(lambda value, obj=None: progressCallback(value*100.0/(2 if order else 1))) if progressCallback else None) 
    4747    if order: 
    48         orderLeaves(root, matrix, progressCallback=(lambda value: progressCallback(50.0 + value/2)) if progressCallback else None) 
     48        order_leaves(root, matrix, progressCallback=(lambda value: progressCallback(50.0 + value/2)) if progressCallback else None) 
    4949    return root 
    5050 
     
    116116                        k0 = orderedKs[0] 
    117117                        curMin = 1e30000  
    118                         curMK = () 
     118                        curM = curK = None 
    119119                        for m in orderedMs: 
    120120                            if M[tree_left, u, m] + M[tree_right, w, k0] + C >= curMin: 
     
    123123                                if M[tree_left, u, m] + M[tree_right, w, k] + C >= curMin: 
    124124                                    break 
    125                                 if curMin > M[tree_left, u, m] + M[tree_right, w, k] + matrix[m, k]: 
    126                                     curMin = M[tree_left, u, m] + M[tree_right, w, k] + matrix[m, k] 
    127                                     curMK = (m, k) 
     125                                testMin = M[tree_left, u, m] + M[tree_right, w, k] + matrix[m, k] 
     126                                if curMin > testMin: 
     127                                    curMin = testMin 
     128                                    curM = m 
     129                                    curK = k 
    128130                        M[tree, u, w] = M[tree, w, u] = curMin 
    129                         ordering[tree, u, w] = (tree_left, u, curMK[0], tree_right, w, curMK[1]) 
    130                         ordering[tree, w, u] = (tree_right, w, curMK[1], tree_left, u, curMK[0]) 
     131                        ordering[tree, u, w] = (tree_left, u, curM, tree_right, w, curK) 
     132                        ordering[tree, w, u] = (tree_right, w, curK, tree_left, u, curM) 
    131133                    else: 
    132134                        def MFunc((m, k)): 
Note: See TracChangeset for help on using the changeset viewer.