def cluster(self, nclusters, linkage_method=linkage.WARD, **kwargs):
        """
        Do hierarchical clustering on a distance matrix using one of the methods:
            methods.SINGLE   = single-linkage clustering
            methods.COMPLETE = complete-linkage clustering
            methods.AVERAGE  = average-linkage clustering
            methods.WARD     = Ward's minimum variance method
        """

        if linkage_method == linkage.SINGLE:
            return self._hclust(nclusters, 'single', **kwargs)
        elif linkage_method == linkage.COMPLETE:
            return self._hclust(nclusters, 'complete', **kwargs)
        elif linkage_method == linkage.AVERAGE:
            return self._hclust(nclusters, 'average', **kwargs)
        elif linkage_method == linkage.WARD:
            return self._hclust(nclusters, 'ward', **kwargs)
        elif linkage_method == linkage.WEIGHTED:
            return self._hclust(nclusters, 'weighted', **kwargs)
        elif linkage_method == linkage.CENTROID:
            return self._hclust(nclusters, 'centroid', **kwargs)
        elif linkage_method == linkage.MEDIAN:
            return self._hclust(nclusters, 'median', **kwargs)
        else:
            raise ValueError('Unknown linkage_method: {}'.format(linkage_method))
def cluster ( self , nclusters , linkage_method = linkage . WARD , ** kwargs ) : if linkage_method == linkage . SINGLE : return self . _hclust ( nclusters , 'single' , ** kwargs ) elif linkage_method == linkage . COMPLETE : return self . _hclust ( nclusters , 'complete' , ** kwargs ) elif linkage_method == linkage . AVERAGE : return self . _hclust ( nclusters , 'average' , ** kwargs ) elif linkage_method == linkage . WARD : return self . _hclust ( nclusters , 'ward' , ** kwargs ) elif linkage_method == linkage . WEIGHTED : return self . _hclust ( nclusters , 'weighted' , ** kwargs ) elif linkage_method == linkage . CENTROID : return self . _hclust ( nclusters , 'centroid' , ** kwargs ) elif linkage_method == linkage . MEDIAN : return self . _hclust ( nclusters , 'median' , ** kwargs ) else : raise ValueError ( 'Unknown linkage_method: {}' . format ( linkage_method ) )
Do hierarchical clustering on a distance matrix using one of the methods:
            methods.SINGLE   = single-linkage clustering
            methods.COMPLETE = complete-linkage clustering
            methods.AVERAGE  = average-linkage clustering
            methods.WARD     = Ward's minimum variance method