import pandas as pd
from minepy import MINE
import numpy as np
from sklearn.preprocessing import MinMaxScaler

# Read Excel file
df = pd.read_excel('wh176_240150_2023-04-25.xlsx', sheet_name='Sheet5')

def MIC(t, b):
  # Get data from the 1st and 9th columns, using iloc method to exclude the column titles
  data = df.iloc[:, [t, b]].values
  columns = df.columns
  col_names = columns[t]
  min_max_scaler = MinMaxScaler()
  data_normalized = min_max_scaler.fit_transform(data)
  data_normalized_df = pd.DataFrame(data_normalized)
  # Create MINE object
  mine = MINE(alpha=0.79, c=15, est="mic_approx")
  mine.compute_score(data[:,0], data[:,1])
  mic = mine.mic()
  mic_0 = round(mic, 3)
  # Output the MIC coefficient obtained
  print(col_names, "MIC:", mic_0)

def shuchu(j):
    if j == 8:
        print("Qualified_Size:")
    else:
        print("Throughput:")
    for i in range(8):
        MIC(i, j)

if __name__ == "__main__":
    shuchu(8)