示例#1
0
                      result_matrix[first_header][second_header])
    print("Pearson correlation coefficients have calculated!")
    return result_matrix


def write_to_csv(file_name, headers, data):
    with open(file_name, 'w') as outfile:
        # the first cell is empty
        outfile.write(";" + ";".join(headers) + "\n")
        for first_header in headers:
            outfile.write(first_header)
            for second_header in headers:
                outfile.write(";" + str(data[first_header][second_header][0]) +
                              " " + str(data[first_header][second_header][1]))
            outfile.write("\n")


data_handler = DataHandler()
signals, backgrounds = data_handler.get_separate_training_data()
headers = data_handler.get_headers()

# signals_backgrounds_correlation(headers, signals, backgrounds)

correlation_matrix_signals = pearson_correlation_matrix(headers, signals)
# file_name = "./reports/correlation/Pearson_correlation_signals.csv"
# write_to_csv(file_name, headers, correlation_matrix_signals)

# correlation_matrix_backgrounds = pearson_correlation_matrix(headers, backgrounds)
# file_name = "./reports/correlation/Pearson_correlation_backgrounds.csv"
# write_to_csv(file_name, headers, correlation_matrix_backgrounds)