File size: 761 Bytes
ff522d1
e9321a8
 
ff522d1
 
 
 
 
e9321a8
 
 
 
 
 
ff522d1
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)