Changeset 9027:5bde2188a76e in orange


Ignore:
Timestamp:
09/27/11 12:23:22 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
2f30f0a5c356a4218a32e65a20d87a3916b5d2ca
Message:

Added order_leaves_cpp function, exposes the core.HierarchicalClusterOrdering class.

File:
1 edited

Legend:

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

    r8764 r9027  
    591591    return cmap 
    592592 
    593 def order_leaves(tree, matrix, progressCallback=None): 
     593def order_leaves_py(tree, matrix, progressCallback=None): 
    594594    """Order the leaves in the clustering tree. 
    595595     
     
    784784        tree.mapping.setattr("objects", objects) 
    785785 
     786def order_leaves_cpp(tree, matrix, progress_callback=None): 
     787    """ Order the leaves in the clustering tree (C++ implementation). 
     788     
     789    (based on Ziv Bar-Joseph et al. (Fast optimal leaf ordering for hierarchical clustering)) 
     790     
     791    :param tree: Binary hierarchical clustering tree. 
     792    :type tree: :class:`HierarchicalCluster` 
     793    :param matrix: SymMatrix that was used to compute the clustering. 
     794    :type matrix: :class:`Orange.core.SymMatrix` 
     795    :param progress_callback: Function used to report on progress. 
     796    :type progress_callback: function 
     797     
     798    .. note:: The ordering is done inplace. 
     799     
     800    """ 
     801    node_count = iter(range(len(tree))) 
     802     
     803    if progress_callback is not None: 
     804        def p(*args): 
     805            progress_callback(100.0 * node_count.next() / len(tree)) 
     806    else: 
     807        p = None 
     808     
     809    Orange.core.HierarchicalClusterOrdering(tree, matrix, progress_callback=p) 
     810     
     811## The cpp code still needs testing 
     812order_leaves = order_leaves_py 
     813     
    786814""" Matplotlib dendrogram ploting. 
    787815""" 
Note: See TracChangeset for help on using the changeset viewer.