Exemplo n.º 1
0
'''
Train the feed-forward classifier on (de-noised) target.
'''
denoiseTarget, preprocessor = dh.standard_scale(denoiseTarget,
                                                preprocessor = None)

if loadModel:
    from keras.models import load_model
    cellClassifier = load_model(os.path.join(io.DeepLearningRoot(),
                                'savemodels/' + dataSet[choice] +
                                '/cellClassifier.h5'))
else:
    print('Train the classifier on de-noised Target')
    cellClassifier = net.trainClassifier(denoiseTarget, mode, refSampleInd,
                                         hiddenLayersSizes,
                                         activation,
                                         l2_penalty,
                                         dataSet[choice])
end = tm.time()
print('Training time: ' + str(end - start))
    
'''
Test the performance with and without calibration.
'''
# Generate the output table.
dim = 2 if isCalibrate else 1    
acc = np.zeros((testIndex.size, dim), np.float16)
F1 = np.zeros((testIndex.size, dim), np.float16)
Testing_time = np.zeros((testIndex.size, dim), np.float16)
mmd_before = np.zeros(testIndex.size)
mmd_after = np.zeros(testIndex.size)
Exemplo n.º 2
0
                                  skip_header=1)

    # Pre-process sample.
    print('Pre-process sample ', str(i + 1))
    sample = dh.preProcessSamplesCyTOFData(sample)
    sample, preprocessor = dh.standard_scale(sample, preprocessor=None)

    # Split data into training and testing.
    print('Split data into training and testing.')
    trainSample, testSample = dh.splitData(sample, test_size=.75)

    # Train a feed-forward neural net classifier on the training data.
    print('Train a feed-forward neural net classifier on the training data.')
    classifier = net.trainClassifier(trainSample,
                                     dataSet[choice],
                                     i,
                                     hiddenLayersSizes,
                                     activation=activation,
                                     l2_penalty=l2_penalty)

    # Run the classifier on the testing data.
    print('Run the classifier on the testing data.')
    acc[i - 1], F1[i - 1], _ = net.prediction(testSample, dataSet[choice], i,
                                              classifier)
'''
Output the overall results.
'''
CI = np.zeros(10000)
for i in range(10000):
    CI[i] = np.mean(np.random.choice(F1, size=30))
CI = np.sort(CI)
print(dataSet[choice], ', ', np.mean(CI), ' (', CI[250], CI[9750], ')')