I want to calculate the mode of a big numpy array for every 16 elements in the array. I saved the array in a csv file. I opened the file and for every 16 elements, I want to calculate the mode and save the result in another file. If there are no more than 16 elements, I want to perform majority voting anyway. I uploaded the file of predictions. I tried this code below
Thank you
import csv
from scipy.stats import mode
import numpy as np
with open("prediction-pairs-overall.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for i in readCSV:
values,counts = np.unique(readCSV, return_counts=True)
index = np.argmax(counts) ##maximum values
mode=values[index]
print(mode)
#input()