def fit(self, X, y=None):
        """Fit detector. y is ignored in unsupervised methods.

        Parameters
        ----------
        X : numpy array of shape (n_samples, n_features)
            The input samples.

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

        Returns
        -------
        self : object
            Fitted estimator.
        """

        # validate inputs X and y (optional)
        X = check_array(X)
        self._set_n_classes(y)

        n_samples, _ = X.shape
        if (isinstance(self.subset_size, int) is True) and (
                not 0 < self.subset_size <= n_samples):
            raise ValueError(
                "subset_size=%r must be between 0 and n_samples=%r."
                % (self.subset_size, n_samples)
            )
        if isinstance(self.subset_size, float) is True:
            if 0.0 < self.subset_size <= 1.0:
                self.subset_size = int(self.subset_size * n_samples)
            else:
                raise ValueError("subset_size=%r must be between 0.0 and 1.0")

        random_indices = self.random_state.choice(
            n_samples,
            size=self.subset_size,
            replace=False,
        )
        self.subset = X[random_indices, :]

        if self.metric_params is None:
            self.dist = DistanceMetric.get_metric(self.metric)
        else:
            self.dist = DistanceMetric.get_metric(self.metric,
                                                  **self.metric_params)

        pair_dist = self.dist.pairwise(X, self.subset)
        anomaly_scores = np.min(pair_dist, axis=1)

        self.decision_scores_ = anomaly_scores
        self._process_decision_scores()

        return self
Fit detector. y is ignored in unsupervised methods.

        Parameters
        ----------
        X : numpy array of shape (n_samples, n_features)
            The input samples.

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

        Returns
        -------
        self : object
            Fitted estimator.
        
pyod/models/sampling.py