def fit(self, X):
        """Fit counterfactual. Compute problem data to generate counterfactual
        explanations.

        Parameters
        ----------
        X : pandas.DataFrame (n_samples, n_features)
            Training vector, where n_samples is the number of samples.

        Returns
        -------
        self : Counterfactual
            Fitted counterfactual.
        """
        time_init = time.perf_counter()

        if self.verbose:
            logger.info("Counterfactual fit started.")
            logger.info("Options: check parameters.")

        _check_parameters(**self.get_params(deep=False))

        if not isinstance(X, pd.DataFrame):
            raise TypeError("X must be a pandas.DataFrame.")

        # Scorecard selected variables
        self._variable_names = self.scorecard.binning_process_.get_support(
            names=True)

        for v in self._variable_names:
            if v not in X.columns:
                raise ValueError("Variable {} not in X. X must include {}."
                                 .format(v, self._variable_names))

        if self.verbose:
            logger.info("Compute optimization problem data.")

        # Problem data
        intercept, coef, min_p, max_p, wrange, F, mu = problem_data(
            self.scorecard, X[self._variable_names])

        self._intercept = intercept
        self._coef = coef
        self._min_p = min_p
        self._max_p = max_p
        self._wrange = wrange
        self._F = F
        self._mu = mu

        self._time_fit = time.perf_counter() - time_init

        if self.verbose:
            logger.info("Counterfactual fit terminated. Time: {:.4f}s"
                        .format(self._time_fit))

        self._is_fitted = True
        self._is_generated = False

        return self
Fit counterfactual. Compute problem data to generate counterfactual
        explanations.

        Parameters
        ----------
        X : pandas.DataFrame (n_samples, n_features)
            Training vector, where n_samples is the number of samples.

        Returns
        -------
        self : Counterfactual
            Fitted counterfactual.
        
optbinning/scorecard/counterfactual/counterfactual.py