def analysis(self, print_output=True):
        """Binning table analysis.

        Statistical analysis of the binning table, computing the Jensen-shannon
        divergence and the quality score. Additionally, a statistical
        significance test between consecutive bins of the contingency table is
        performed using the Chi-square test.

        Parameters
        ----------
        print_output : bool (default=True)
            Whether to print analysis information.

        Notes
        -----
        The Chi-square test uses `scipy.stats.chi2_contingency
        <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.
        chi2_contingency.html>`_.
        """
        _check_is_built(self)

        # Significance tests
        n_bins = len(self._n_records)
        n_metric = n_bins - 1 - self._n_specials

        n_ev = self.n_event[:n_metric, :]
        if len(n_ev) >= 2:
            chi2, cramer_v = chi2_cramer_v_multi(n_ev)
        else:
            cramer_v = 0

        t_statistics = []
        p_values = []
        for i in range(n_metric-1):
            obs = n_ev[i:i+2, :]
            t_statistic, p_value = frequentist_pvalue(obs, "chi2")

            t_statistics.append(t_statistic)
            p_values.append(p_value)

        df_tests = pd.DataFrame({
                "Bin A": np.arange(n_metric-1),
                "Bin B": np.arange(n_metric-1) + 1,
                "t-statistic": t_statistics,
                "p-value": p_values
            })

        tab = 4
        if len(df_tests):
            df_tests_string = dataframe_to_string(df_tests, tab)
        else:
            df_tests_string = " " * tab + "None"

        # Quality score
        self._quality_score = multiclass_binning_quality_score(
            self._js, len(self.classes), p_values, self._hhi_norm)

        # Monotonic trend
        mono_string = "    Class {:>2}            {:>15}\n"
        monotonic_string = ""

        for i in range(len(self.classes)):
            type_mono = type_of_monotonic_trend(self._event_rate[:-2, i])
            monotonic_string += mono_string.format(i, type_mono)

        report = (
            "-------------------------------------------------\n"
            "OptimalBinning: Multiclass Binning Table Analysis\n"
            "-------------------------------------------------\n"
            "\n"
            "  General metrics"
            "\n\n"
            "    JS (Jensen-Shannon) {:>15.8f}\n"
            "    HHI                 {:>15.8f}\n"
            "    HHI (normalized)    {:>15.8f}\n"
            "    Cramer's V          {:>15.8f}\n"
            "    Quality score       {:>15.8f}\n"
            "\n"
            "  Monotonic trend\n\n{}"
            "\n"
            "  Significance tests\n\n{}\n"
            ).format(self._js, self._hhi, self._hhi_norm, cramer_v,
                     self._quality_score, monotonic_string, df_tests_string)

        if print_output:
            print(report)

        self._is_analyzed = True
Binning table analysis.

        Statistical analysis of the binning table, computing the Jensen-shannon
        divergence and the quality score. Additionally, a statistical
        significance test between consecutive bins of the contingency table is
        performed using the Chi-square test.

        Parameters
        ----------
        print_output : bool (default=True)
            Whether to print analysis information.

        Notes
        -----
        The Chi-square test uses `scipy.stats.chi2_contingency
        <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.
        chi2_contingency.html>`_.
        
optbinning/binning/binning_statistics.py