Пример #1
0
    def partial_fit(self, X, y=None):
        """Update k means estimate on a single mini-batch X.
        Parameters
        ----------
        X : array-like, shape = [n_samples, rows, cols, channels]
            Coordinates of the data points to cluster.
        y : Ignored
        """
        X = check_image_array(self, X)

        return self._partial_fit(X, y)
Пример #2
0
    def fit(self, X, y=None):
        """Compute the centroids on X by chunking it into mini-batches.
        Parameters
        ----------
        X : array-like or sparse matrix, shape = [n_samples, rows, cols, channels]
            Training instances to cluster.
        y : Ignored
        """
        X = check_image_array(self, X)

        return self._fit(X, y)
Пример #3
0
    def predict(self, X):
        """Predict the closest cluster each sample in X belongs to.
        In the vector quantization literature, `cluster_centers_` is called
        the code book and each value returned by `predict` is the index of
        the closest code in the code book.
        Parameters
        ----------
        X : {array-like, sparse matrix}, shape = [n_samples, rows, cols, channels]
            New data to predict.
        Returns
        -------
        labels : array, shape [n_samples,]
            Index of the cluster each sample belongs to.
        """
        check_is_fitted(self, "cluster_centers_")
        X = check_image_array(self, X)

        return self._predict(X)