I designed the accuracy function and tried to run it twice but it takes a lot of time and the execution didn’t stop.
function:
def get_acc(x_train,y_train,x_tst,y_tst):
m = x_tst.shape[0]
y_pred = []
for i in range(m):
pred = KNN(x_train,y_train,x_tst[i])
y_pred.append(pred)
y_pred = np.array(y_pred)
return float((y_pred==y_tst).sum())/y_tst.shape[0]
This is the function that i wrote for accuracy. Pls check and tell for mistakes.