ax[0, 0].set_title('ROC Curves') ax[0, 1].set_title('Sensivity at Lead Time') ax[-1, 0].set_xlabel('False Positive Rate') ax[-1, 1].set_xlabel('Lead Time (h)') plot_path = '/home/alex/mews/images/metrics/' for f, period in enumerate(periods): for i, (mews_scorer, data_level) in enumerate( zip([utils.base, np.median, utils.worst_case], [False, False, True])): if mews_scorer.__name__ == 'base': case, _ = mews.prepare_case_multiple(period=False, scorer=mews_scorer, data_level=data_level) control, _ = mews.prepare_control(period=False, scorer=mews_scorer, data_level=data_level) else: case, _ = mews.prepare_case_multiple(period=period, scorer=mews_scorer, data_level=data_level) control, _ = mews.prepare_control(period=period, scorer=mews_scorer, data_level=data_level) case_processor = Process(thresholds=thresh, scorers=case_scorers, augmenter=augmenter).per_data
from performance.core import mews, metrics import numpy as np import matplotlib matplotlib.use('Agg') from scipy.stats import wilcoxon from performance.core import scorers, Process, augmenters if __name__ == '__main__': case, _ = mews.prepare_case_multiple() thresh = np.arange(4, 5) + 3 scorers = [scorers.PosNeg(tmin=0, tmax=np.inf)] augmenter = augmenters.ShuffleEventMax(num_samples=1000, max_time=1) random_processor = Process(thresholds=thresh, scorers=scorers, augmenter=augmenter).per_data augment = augmenters.NoAugment() processor = Process(thresholds=thresh, scorers=scorers, augmenter=augmenter).per_data counts, raw_counts = metrics.run(case, processor) random_counts, random_raw_counts = metrics.run(case, random_processor) print(random_counts[0].shape) x = ((np.array(random_counts[0])[:, :, 0] - counts[0][:, :, 0]) / case.shape[0]).reshape(-1, )
from performance.core import mews, utils matplotlib.use('Agg') from matplotlib import pyplot as plt path = '/home/alex/mews/images/profiles/' for data_level in [True, False]: l = [np.max, utils.mode, np.median, np.mean] if data_level: l += [utils.worst_case] for mews_scorer in l: print(mews_scorer.__name__) for period in [1, 2, 4, 8]: prepared_case, case = mews.prepare_case_multiple( period=period, scorer=mews_scorer, data_level=data_level) for i, k in enumerate(np.unique(prepared_case[:, 0])): cur_data = case[k] inds = np.where(prepared_case[:, 0] == k)[0] f, ax = plt.subplots(6, 1, figsize=(20, 20)) ax[0].stem(prepared_case[inds, 1], prepared_case[inds, 2]) ax[0].set_xlim([24, 0]) ax[0].set_title('MEWS Score') ax[1].set_title('Vital Signs for Calculated MEWS') for j, (vital, label) in enumerate( zip([ 'BLOOD PRESSURE SYSTOLIC', 'PULSE', 'R CPN GLASGOW COMA SCALE SCORE', 'RESPIRATIONS', 'TEMPERATURE' ], [