Пример #1
0
    del train_data_gen
    del val_data_gen

    # Testing ihm
    from mimic3benchmark.readers import InHospitalMortalityReader
    from mimic3models.in_hospital_mortality.utils import read_chunk
    from mimic3models import nn_utils

    test_reader = InHospitalMortalityReader(dataset_dir='../../data/in-hospital-mortality/test/',
                    listfile='../../data/in-hospital-mortality/test_listfile.csv',
                    period_length=48.0)

    ihm_y_true = []
    ihm_pred = []

    n_examples = test_reader.get_number_of_examples()
    for i in range(0, n_examples, args.batch_size):
        j = min(i + args.batch_size, n_examples)
        (X, ts, labels, header) = read_chunk(test_reader, j - i)

        for i in range(args.batch_size):
            X[i] = discretizer.transform(X[i], end=48.0)[0]
            X[i] = normalizer.transform(X[i])

        X = nn_utils.pad_zeros(X, min_length=args_dict['ihm_pos']+1)
        T = X.shape[1]
        ihm_M = np.ones(shape=(args.batch_size,1))
        decomp_M = np.ones(shape=(args.batch_size, T))
        los_M = np.ones(shape=(args.batch_size, T))

        pred = model.predict([X, ihm_M, decomp_M, los_M])[0]
Пример #2
0
    del val_data_gen

    # Testing ihm
    from mimic3benchmark.readers import InHospitalMortalityReader
    from mimic3models.in_hospital_mortality.utils import read_chunk
    from mimic3models import nn_utils

    test_reader = InHospitalMortalityReader(
        dataset_dir='../../data/in-hospital-mortality/test/',
        listfile='../../data/in-hospital-mortality/test_listfile.csv',
        period_length=48.0)

    ihm_y_true = []
    ihm_pred = []

    nsteps = test_reader.get_number_of_examples() // args.batch_size
    for iteration in range(nsteps):
        (X, ts, labels, header) = read_chunk(test_reader, args.batch_size)

        for i in range(args.batch_size):
            X[i] = discretizer.transform(X[i], end=48.0)[0]
            X[i] = normalizer.transform(X[i])

        X = nn_utils.pad_zeros(X, min_length=args_dict['ihm_pos'] + 1)
        T = X.shape[1]
        ihm_M = np.ones(shape=(args.batch_size, 1))
        decomp_M = np.ones(shape=(args.batch_size, T))
        los_M = np.ones(shape=(args.batch_size, T))

        pred = model.predict([X, ihm_M, decomp_M, los_M])[0]
        ihm_y_true += labels