ecg-classification / make_predictions.py
nabeelraza's picture
Add: included butter filter
e9321a8
raw
history blame contribute delete
761 Bytes
import numpy as np
from read_data import prepare_all_leads, visualize_sig
from postprocessing import predict_disease, labels_map
from scipy import stats as st
import warnings
warnings.filterwarnings("ignore")
def make_prediction(path, visualize=False, butter_filter=True):
leads = prepare_all_leads(path, butter_filter=butter_filter)
visualize_sig([leads[0][0], leads[1][0], leads[2][0]]) if visualize else None
all, x, y, z = predict_disease(*leads)
index = st.mode(np.argmax(all, axis=1))[0][0]
confidence = all.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)