Spaces:
Runtime error
Runtime error
import numpy as np | |
from read_data import prepare_all_leads | |
from postprocessing import make_predictions_indi, labels_map | |
from scipy import stats as st | |
import warnings | |
warnings.filterwarnings("ignore") | |
def make_prediction(path): | |
leads = prepare_all_leads(path) | |
# print(leads[0][0].shape) | |
# print(leads[1][0].shape) | |
# print(leads[2][0].shape) | |
# visualize_sig([leads[0][0], leads[1][0], leads[2][0]]) | |
x = make_predictions_indi(*leads) | |
# print(x.mean(axis=0)) | |
# print(np.argmax(x, axis=1)) | |
index = st.mode(np.argmax(x, axis=1))[0][0] | |
confidence = x.mean(axis=0)[index] | |
return labels_map[index], float(confidence) | |
if __name__ == "__main__": | |
prediction = make_prediction("data/faizan_r8.txt") | |
# prediction = make_prediction("data/a_fib.npy") | |
print(prediction) |