def METHOD_NAME(self, X, y=None):
    """Learn empirical variances from X.
    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        Data from which to compute variances, where `n_samples` is
        the number of samples and `n_features` is the number of features.
    y : any, default=None
        Ignored. This parameter exists only for compatibility with
        sklearn.pipeline.Pipeline.
    Returns
    -------
    self : object
        Returns the instance itself.
    """
    self._validate_params()
    X = self._validate_data(
        X,
        accept_sparse=("csr", "csc"),
        dtype=np.float64,
        force_all_finite="allow-nan",
    )
    if hasattr(X, "toarray"):  # sparse matrix
        _, self.variances_ = mean_variance_axis(X, axis=0)
        if self.threshold == 0:
            mins, maxes = min_max_axis(X, axis=0)
            peak_to_peaks = maxes - mins
    else:
        self.variances_ = np.nanvar(X, axis=0)
        if self.threshold == 0:
            peak_to_peaks = np.ptp(X, axis=0)
    if self.threshold == 0:
        # Use peak-to-peak to avoid numeric precision issues
        # for constant features
        compare_arr = np.array([self.variances_, peak_to_peaks])
        self.variances_ = np.nanmin(compare_arr, axis=0)
    if np.all(~np.isfinite(self.variances_) | (self.variances_ <= self.threshold)):
        msg = "No feature in X meets the variance threshold {0:.5f}"
        if X.shape[0] == 1:
            msg += " (X contains only one sample)"
        raise ValueError(msg.format(self.threshold))
    return self