Changeset 10160:523ea3894b22 in orange


Ignore:
Timestamp:
02/11/12 10:31:08 (2 years ago)
Author:
markotoplak
Branch:
default
Message:

Changes so Orange.hierarchical documentation.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Orange/clustering/hierarchical.py

    r10147 r10160  
    99.. index:: aglomerative clustering 
    1010 
    11 For hierarchical clustering we need to compute distances between 
    12 instances. The method works in approximately O(n2) time (with the worst 
    13 case O(n3)).   
    14  
    15 The distance matrix has to contain no negative elements, as this helps 
    16 the algorithm to run faster. The elements on the diagonal are ignored. 
    17  
    18 .. rubric:: Example 
    19  
    20 The following example show clustering of the Iris data, Distance matrix 
    21 is computed with the :class:`Orange.distance.Euclidean` distance measure 
     11The following example show clustering of the Iris data, with distance matrix 
     12computed with the :class:`Orange.distance.Euclidean` distance measure 
    2213and cluster it with average linkage. 
    2314 
     
    6051    .. attribute:: linkage 
    6152         
    62         Specifies the linkage method, which can be either : 
    63          
    64             1. ``HierarchicalClustering.Single`` (default), where distance 
    65                 between groups is defined as the distance between the closest 
    66                 pair of objects, one from each group, 
    67             2. ``HierarchicalClustering.Average`` , where the distance between 
    68                 two clusters is defined as the average of distances between 
    69                 all pairs of objects, where each pair is made up of one object 
    70                 from each group, or 
    71             3. ``HierarchicalClustering.Complete``, where the distance between 
    72                 groups is defined as the distance between the most distant 
    73                 pair of objects, one from each group. Complete linkage is 
    74                 also called farthest neighbor. 
    75             4. ``HierarchicalClustering.Ward`` uses Ward's distance. 
    76              
     53        Specifies the linkage method, which can be either. Default is 
     54        :obj:`SINGLE`. 
     55 
    7756    .. attribute:: overwrite_matrix 
    7857 
     
    8867    .. method:: __call__(matrix) 
    8968           
    90         The ``HierarchicalClustering`` is called with a distance matrix as an 
    91         argument. It returns an instance of HierarchicalCluster representing 
     69        Return an instance of HierarchicalCluster representing 
    9270        the root of the hierarchy (instance of :class:`HierarchicalCluster`). 
    93          
     71 
     72        The distance matrix has to contain no negative elements, as 
     73        this helps the algorithm to run faster. The elements on the 
     74        diagonal are ignored. The method works in approximately O(n2) 
     75        time (with the worst case O(n3)). 
     76 
    9477        :param matrix: A distance matrix to perform the clustering on. 
    9578        :type matrix: :class:`Orange.misc.SymMatrix` 
    9679 
     80.. rubric:: Linkage methods 
     81 
     82.. data:: SINGLE 
     83 
     84    Distance between groups is defined as the distance between the closest 
     85                pair of objects, one from each group. 
     86 
     87.. data:: AVERAGE 
     88 
     89    Distance between two clusters is defined as the average of distances 
     90    between all pairs of objects, where each pair is made up of one 
     91    object from each group. 
     92 
     93.. data:: COMPLETE 
     94 
     95    Distance between groups is defined as the distance between the most 
     96    distant pair of objects, one from each group. Complete linkage is 
     97    also called farthest neighbor. 
     98 
     99.. data:: WARD 
     100 
     101    Ward's distance. 
     102  
    97103Drawing 
    98104-------------- 
     
    355361               progress_callback=None): 
    356362    """ Return a hierarchical clustering of the instances in a data set. 
    357      
     363    The method works in approximately O(n2) time (with the worst case O(n3)). 
     364    
    358365    :param data: Input data table for clustering. 
    359366    :type data: :class:`Orange.data.Table` 
    360367    :param distance_constructor: Instance distance constructor 
    361368    :type distance_constructor: :class:`Orange.distance.DistanceConstructor` 
    362     :param linkage: Linkage flag. Must be one of global module level flags: 
    363      
    364         - SINGLE 
    365         - AVERAGE 
    366         - COMPLETE 
    367         - WARD 
     369    :param linkage: Linkage flag. Must be one of module level flags: 
     370     
     371        - :obj:`SINGLE` 
     372        - :obj:`AVERAGE` 
     373        - :obj:`COMPLETE` 
     374        - :obj:`WARD` 
    368375         
    369376    :type linkage: int 
     
    392399 
    393400 
    394 def clustering_features(data, distance=None, linkage=orange.HierarchicalClustering.Average, order=False, progress_callback=None): 
     401def clustering_features(data, distance=None, linkage=AVERAGE, order=False, progress_callback=None): 
    395402    """ Return hierarchical clustering of attributes in a data set. 
    396403     
     
    398405    :type data: :class:`Orange.data.Table` 
    399406    :param distance: Attribute distance constructor  (currently not used). 
    400     :param linkage: Linkage flag. Must be one of global module level flags: 
     407    :param linkage: Linkage flag; one of global module level flags: 
    401408     
    402409        - SINGLE 
  • docs/reference/rst/code/hierarchical-example-2.py

    r10106 r10160  
    77 
    88clustering = Orange.clustering.hierarchical.HierarchicalClustering() 
    9 clustering.linkage = clustering.Average 
     9clustering.linkage = Orange.clustering.hierarchical.AVERAGE 
    1010root = clustering(matrix) 
    1111 
  • docs/reference/rst/code/hierarchical-example-3.py

    r10106 r10160  
    55root = Orange.clustering.hierarchical.clustering(iris, 
    66    distance_constructor=Orange.distance.Euclidean, 
    7     linkage=Orange.clustering.hierarchical.HierarchicalClustering.Average) 
     7    linkage=Orange.clustering.hierarchical.AVERAGE) 
    88 
    99root.mapping.objects = iris 
  • docs/reference/rst/code/hierarchical-example.py

    r10106 r10160  
    1414matrix = Orange.misc.SymMatrix(m) 
    1515root = Orange.clustering.hierarchical.HierarchicalClustering(matrix, 
    16         linkage=Orange.clustering.hierarchical.HierarchicalClustering.Average) 
     16        linkage=Orange.clustering.hierarchical.AVERAGE) 
    1717 
    1818def print_clustering(cluster): 
Note: See TracChangeset for help on using the changeset viewer.