def compare_toymc(data, clustering_features=None):
    """Prints comparison of distributions: original one and generated toyMC.
    Should be used in IPython notebook.
    :param pandas.DataFrame data: the dataset we generate toyMC for.
    :type clustering_features: list | None, very close to integer ones, usually have some bool or integer values,
        but events with different values in these columns should not be mixed together
        example: 'isSignal', number of muons
    :type integer_features: list | None, features that have some discrete values, but events can be mixed together
        if they have different values in these columns, the result will be integer
        example: some weight of event, which should be integer due to technical restrictions, isolation vars.
    """
    assert isinstance(data, pandas.DataFrame), 'need a Pandas.DataFrame here'
    from IPython.display import display_html

    def print_title(title):
        display_html("<h3>{}</h3>".format(title), raw=True)

    toy_data = generate_toymc_with_special_features(data, len(data), clustering_features=clustering_features)

    numpy.set_printoptions(precision=4, suppress=True)
    n_cols = 3
    n_rows = (len(data.columns) + n_cols - 1) // n_cols
    pylab.figure(figsize=(18, 5 * n_rows))
    for i, column in enumerate(data.columns, 1):
        pylab.subplot(n_rows, n_cols, i)
        pylab.title(column)
        pylab.hist([data[column].values, toy_data[column].values], histtype='step', bins=20)
    pylab.show()

    print_title("Means and std")
    mean_index = []
    mean_rows = []
    for column in data.columns:
        mean_index.append(column)
        mean1 = numpy.mean(data[column])
        mean2 = numpy.mean(toy_data[column])
        std1 = numpy.std(data[column])
        std2 = numpy.std(toy_data[column])
        mean_rows.append([mean1, mean2, mean2 - mean1, abs((mean1-mean2) * 100. / mean1),
                          std1, std2, std2 - std1, abs((std2 - std1) * 100. / std1)])

    display_html(pandas.DataFrame(mean_rows, index=mean_index,
        columns=['mean orig', 'mean toy', 'difference', 'error, %', 'std orig', 'std toy', 'difference', 'error, %']))

    print_title('Covariance')
    cov_index = []
    cov_rows = []
    for i, first_column in enumerate(data.columns, ):
        for second_column in data.columns[i+1:]:
            cov_index.append((first_column, second_column))
            data_cov = pearsonr(data[first_column], data[second_column])[0]
            toy_cov = pearsonr(toy_data[first_column], toy_data[second_column])[0]
            cov_rows.append([data_cov, toy_cov, toy_cov-data_cov, abs((data_cov - toy_cov) * 100. / data_cov)])
    display_html(pandas.DataFrame(cov_rows, index=cov_index, columns=['original', 'toy', 'difference', 'error, %']))

    for col, first_column in enumerate(data.columns[:4]):
        for second_column in data.columns[col + 1:4]:
            x_min = numpy.min(data[first_column])
            x_max = numpy.max(data[first_column])
            y_min = numpy.min(data[second_column])
            y_max = numpy.max(data[second_column])

            pylab.figure(figsize=(12, 5))
            pylab.subplot(121)
            pylab.plot(data[first_column], data[second_column], '.', alpha=0.1)
            pylab.xlim(x_min, x_max), pylab.ylim(y_min, y_max)
            pylab.title("original data")

            pylab.subplot(122)
            pylab.plot(toy_data[first_column], toy_data[second_column], '.', alpha=0.1)
            pylab.ylim(y_min, y_max), pylab.xlim(x_min, x_max)
            pylab.title("toy MC")

            pylab.suptitle("{} vs {}".format(first_column, second_column))
            pylab.show()
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/toymc.py/compare_toymc/original