import random
import numpy as np
from scipy.interpolate import griddata
def ts_score_function(sample_data, threshold=-1):
sample_data = np.delete(sample_data, sample_data[:, 1] < threshold, 0)
na = 0
nb = 0
nc = 0
nd = 0
for i in range(len(sample_data)):
if sample_data[i, 0] > 0 and sample_data[i, 1] > 0:
na = na + 1
elif sample_data[i, 0] == 0 and sample_data[i, 1] > 0:
nb = nb + 1
elif sample_data[i, 0] > 0 and sample_data[i, 1] == 0:
nc = nc + 1
elif sample_data[i, 0] == 0 and sample_data[i, 1] == 0:
nd = nd + 1
ts_score = (na + nd) / (na + nb + nc + nd)
return ts_score
if __name__ == '__main__':
random_int_list1 = random.sample(range(0, 500), 100)
random_int_list2 = random.sample(range(0, 500), 100)
sample_data = np.vstack([np.array(random_int_list1), np.array(random_int_list2)]).T
reslut = ts_score_function(sample_data, 100)