(self, X, y=None)
return self
Fit the agglomerative clustering from features or distance matrix.

        The stopping rule is used to determine :attr:`n_clusters_`, and the
        full dendrogram is cut there to compute :attr:`labels_`.

        Parameters
        ----------
        X : ndarray of shape (n_samples, n_features) or (n_samples, n_samples)
            Training instances to cluster, or distances between instances if
            ``affinity='precomputed'``.

        y : ignored
            Not used, present here for API consistency by convention.

        Returns
        -------
        self
Fit the agglomerative clustering from features or distance matrix.
Fit the agglomerative clustering from features or distance matrix .
def fit(self, X, y=None):
        """Fit the agglomerative clustering from features or distance matrix.

        The stopping rule is used to determine :attr:`n_clusters_`, and the
        full dendrogram is cut there to compute :attr:`labels_`.

        Parameters
        ----------
        X : ndarray of shape (n_samples, n_features) or (n_samples, n_samples)
            Training instances to cluster, or distances between instances if
            ``affinity='precomputed'``.

        y : ignored
            Not used, present here for API consistency by convention.

        Returns
        -------
        self

        """
        X = check_array(X)
        validate_params(
            self.get_params(), self._hyperparameters, exclude=['memory'])

        if X.shape[0] == 1:
            self.labels_ = np.array([0])
            self.n_clusters_ = 1
            return self

        self._build_tree(X)

        self.n_clusters_ = _num_clusters_histogram(
            self.distances_, self.freq_threshold, self.n_bins_start,
            self.max_fraction)

        # Cut the tree to find labels
        # TODO: Verify whether Daniel Mullner's implementation of this step
        #  offers any advantage
        self.labels_ = _hc_cut(self.n_clusters_, self.children_,
                               self.n_leaves_)
        return self
def fit ( self , X , y = None ) : X = check_array ( X ) validate_params ( self . get_params ( ) , self . _hyperparameters , exclude = [ 'memory' ] ) if X . shape [ 0 ] == 1 : self . labels_ = np . array ( [ 0 ] ) self . n_clusters_ = 1 return self self . _build_tree ( X ) self . n_clusters_ = _num_clusters_histogram ( self . distances_ , self . freq_threshold , self . n_bins_start , self . max_fraction ) # Cut the tree to find labels # TODO: Verify whether Daniel Mullner's implementation of this step #  offers any advantage self . labels_ = _hc_cut ( self . n_clusters_ , self . children_ , self . n_leaves_ ) return self