# process causality results from numpy import genfromtxt import numpy as np import os import pandas as pd hu = [0]*8 hl = [0]*8 su = [0]*8 sl = [0]*8 folder = '/home/valapil/Project/ForkCausal_Adithya/results_causal' csv_files = [file for file in os.listdir(folder) if file.endswith('.npy')] def check(row, expr): if row[3] == 'True' and row[4] == 'True': expr[2] += 1 if row[3] == 'True' and row[4] == 'False': expr[0] += 1 if row[3] == 'False' and row[4] == 'True': expr[1] += 1 if row[3] == 'False' and row[4] == 'False': expr[3] += 1 if row[8] == 'True' and row[9] == 'True': expr[6] += 1 if row[8] == 'True' and row[9] == 'False': expr[4] += 1 if row[8] == 'False' and row[9] == 'True': expr[5] += 1 if row[8] == 'False' and row[9] == 'False': expr[7] += 1 return expr for file in csv_files: file_path = os.path.join(folder, file) # data = pd.read_csv(file_path) data = np.load(file_path) # for index, row in data.iterrows(): for row in data[1:, :]: # row = row.to_list() if row[2] == 'HappinessUpper': hu = check(row, hu) if row[2] == 'HappinessLower': hl = check(row, hl) if row[2] == 'SadnessUpper': su = check(row, su) if row[2] == 'SadnessLower': sl = check(row, sl) print(hl) print(hu) print(sl) print(su)