Ejemplo n.º 1
0
        ])
        sens_opt_thresh_here = np.zeros([
            __N_RUNS,
        ])
        spec_opt_thresh_here = np.zeros([
            __N_RUNS,
        ])

        # Iterate over number of desired runs
        for run_idx in range(__N_RUNS):

            logger.info('\tWorking on run [%2d / %2d]...' %
                        (run_idx + 1, __N_RUNS))

            # Create the cnn model
            model = get_sino_cnn(input_shape=np.shape(train_data)[1:],
                                 lr=0.001)

            # Train the model
            model.fit(x=train_data,
                      y=train_labels,
                      epochs=__N_EPOCHS,
                      shuffle=True,
                      batch_size=2056,
                      verbose=False)

            # Predict on the test set
            test_preds = model.predict(x=test_data)

            # Get metrics at 0.50 decision threshold
            auc = roc_auc_score(y_true=test_labels, y_score=test_preds)
            acc = get_acc(preds=test_preds[:, 1], labels=test_labels[:, 1])
Ejemplo n.º 2
0
    accs = np.zeros([
        n_runs,
    ])
    sens = np.zeros([
        n_runs,
    ])
    spec = np.zeros([
        n_runs,
    ])

    for run_idx in range(n_runs):

        logger.info('\tWorking on run [%d / %d]...' % (run_idx + 1, n_runs))

        # Get model
        cnn = get_sino_cnn(input_shape=np.shape(g2_d)[1:], lr=0.001)

        # Train the model
        cnn.fit(x=g2_d,
                y=g2_labels,
                epochs=__N_EPOCHS,
                shuffle=True,
                batch_size=2048,
                verbose=False)

        # Calculate the predictions
        g1_preds = cnn.predict(x=g1_d)

        # Get and store ROC AUC
        g1_auc = 100 * roc_auc_score(y_true=g1_labels, y_score=g1_preds)
        auc_scores[run_idx] = g1_auc