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_features = X.shape[0], X.shape[1]

        if isinstance(self.n_bins, str) and self.n_bins.lower() == "auto":
            # Uses the birge rozenblac method for automatic histogram size per feature
            self.hist_ = []
            self.bin_edges_ = []

            # build the histograms for all dimensions
            for i in range(n_features):
                n_bins = get_optimal_n_bins(X[:, i])
                hist, bin_edges = np.histogram(X[:, i], bins=n_bins,
                                               density=True)
                self.hist_.append(hist)
                self.bin_edges_.append(bin_edges)
                # the sum of (width * height) should equal to 1
                assert (np.isclose(1, np.sum(
                    hist * np.diff(bin_edges)), atol=0.1))

            outlier_scores = _calculate_outlier_scores_auto(X, self.bin_edges_,
                                                            self.hist_,
                                                            self.alpha,
                                                            self.tol)

        elif check_parameter(self.n_bins, low=2, high=np.inf):
            self.hist_ = np.zeros([self.n_bins, n_features])
            self.bin_edges_ = np.zeros([self.n_bins + 1, n_features])

            # build the histograms for all dimensions
            for i in range(n_features):
                self.hist_[:, i], self.bin_edges_[:, i] = \
                    np.histogram(X[:, i], bins=self.n_bins, density=True)
                # the sum of (width * height) should equal to 1
                assert (np.isclose(1, np.sum(
                    self.hist_[:, i] * np.diff(self.bin_edges_[:, i])),
                                   atol=0.1))

            outlier_scores = _calculate_outlier_scores(X, self.bin_edges_,
                                                       self.hist_,
                                                       self.n_bins,
                                                       self.alpha, self.tol)

        # invert decision_scores_. Outliers comes with higher outlier scores
        self.decision_scores_ = invert_order(np.sum(outlier_scores, axis=1))
        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/hbos.py