def search_best_match()

in causalml/match.py [0:0]


    def search_best_match(self, df):
        self.df = df

        self.original_stats = {}
        for col, trans in self.dev_cols_transformations.items():
            self.original_stats[col] = trans(
                self.df[self.df[self.treatment_col] == 1][col]
            )

        # search best max pihat
        if self.verbose:
            logger.info("SEARCHING FOR BEST PIHAT")
        score_cols = [self.ps_col]
        caliper = self.caliper_range[-1]
        for pihat_threshold in self.max_pihat_range:
            self.match_and_check(score_cols, pihat_threshold, caliper)

        # search best score_cols
        if self.verbose:
            logger.info("SEARCHING FOR BEST SCORE_COLS")
        pihat_threshold = self.best_params["pihat"]
        caliper = self.caliper_range[int(self.caliper_range.shape[0] / 2)]
        score_cols = [self.ps_col]
        while not self.pass_all:
            if len(self.cols_to_fix) == 0:
                break
            elif np.intersect1d(self.cols_to_fix, score_cols).shape[0] > 0:
                break
            else:
                score_cols.append(self.cols_to_fix[0])
                self.match_and_check(score_cols, pihat_threshold, caliper)

        # search best caliper
        if self.verbose:
            logger.info("SEARCHING FOR BEST CALIPER")
        score_cols = self.best_params["score_cols"]
        pihat_threshold = self.best_params["pihat"]
        for caliper in self.caliper_range:
            self.match_and_check(score_cols, pihat_threshold, caliper)

        # summarize
        if self.verbose:
            logger.info("\n-----\nBest params are:\n{}".format(self.best_params))

        return self.best_matched