//  [python]
def testPredict(argsDict, modelPath, type):
        print(f"Running prediction tests with model {argsDict['outputDir']}")
        # test model by predicting on held back data
        # restore from tensorflow
        model = tf.keras.models.load_model(modelPath)
        
        METRICS = [
          TruePositives(name='tp'),
          FalsePositives(name='fp'),
          TrueNegatives(name='tn'),
          FalseNegatives(name='fn'), 
          BinaryAccuracy(name='accuracy'),
          Precision(name='precision'),
          Recall(name='recall'),
          AUC(name='auc'),
          AUC(name='prc', curve='PR'), # precision-recall curve
        ]
        
        lr_decayed_fn = CosineDecayRestarts(initial_learning_rate=0.001, first_decay_steps=300)
        opt_adam=Adam(learning_rate=lr_decayed_fn, epsilon=0.0000001, amsgrad=True)
        model.compile(loss='binary_crossentropy',
                optimizer=opt_adam,
                metrics=METRICS)
        
        # import data to predict
        numberStats = 11
        numberWindowSizes = 5
        numberCenters = int((argsDict['maxCenter'] - argsDict['minCenter'])/argsDict['distCenters']) + 1

        testXDataParams = np.loadtxt(f"{argsDict['fvLoc']}/{type}_predict.fv", skiprows=1, delimiter=',')
        numRows, numCols = testXDataParams.shape
        if type == "neutral" and numCols == 1159:
                print("predicting neutral")
                testX = np.delete(testXDataParams, np.s_[0:4], 1) # get rid of first four columns of simulation parameters
                testXParams = testXDataParams[:,0:4]
        elif type == "neutral" and numCols == 1155:
                print("predicting neutral")
                testXParams = False
        elif type == "sweep" and numCols == 1163: # sweep, extra params are iter, SAF, SEL, TIME, EAF, THETA, RHO
                print("predicting sweep")
                testX=np.delete(testXDataParams, np.s_[0:8], 1) # get rid of first eight columns of simulation parameters
                testXParams=testXDataParams[:,0:8]
        elif type == "sweep" and numCols == 1155:
                print("predicting sweep")
                testXParams = False
        else:
                print(f"Predict fv at {argsDict['fvLoc']}/{type}_predict.fv has {numCols} columns, expected 1155 (if no parameters in feature vector), 1159 (neutral) or 1163 (sweep)")
                sys.exit(1)
        
        y = np.repeat(0, len(testX))
        testX = np.reshape(testX, (testX.shape[0], numberStats, numberWindowSizes * numberCenters))
        testX = testX.reshape(testX.shape[0], numberStats, numberWindowSizes * numberCenters, 1) # batch size, image width, image height, number of channels
        testY = utils.to_categorical(y, 2)
        
        validation_gen = ImageDataGenerator(
                featurewise_center=True,
                featurewise_std_normalization=True,
                horizontal_flip=False)
        
        validation_gen.fit(testX)
        
        # make predictions
        preds = model.predict(validation_gen.standardize(testX))
        predictions = np.argmax(preds,axis=1)
        
        classDict = {1:'neutral',0:'sweep'}
        
        #output the predictions
        os.makedirs(f"{modelPath}/testPredictions", exist_ok=True)
        with open(f"{modelPath}/testPredictions/{type}.preds",'w') as outFile:
                if numCols == 1155:
                        outFile.write('predicted_class\tprob(sweep)\tprob(neutral)\n')
                        for row in range(0,len(preds)):
                                outFile.write(f"{classDict[predictions[row]]}\t{preds[row][0]}\t{preds[row][1]}\n")
                elif numCols == 1155+4:
                        outFile.write('iter\tNE\tMU\tRHO\tpredicted_class\tprob(sweep)\tprob(neutral)\n')
                        for row in range(0,len(preds)):
                                outFile.write(f"{testXParams[row,0]}\t{testXParams[row,1]}\t{testXParams[row,2]}\t{testXParams[row,3]}\t{classDict[predictions[row]]}\t{preds[row][0]}\t{preds[row][1]}\n")
                elif numCols == 1155+8:
                        outFile.write('iter\tNE\tMU\tRHO\tSEL\tTIME\tSAF\tEAF\tpredicted_class\tprob(sweep)\tprob(neutral)\n')
                        for row in range(0,len(preds)):
                                outFile.write(f"{testXParams[row,0]}\t{testXParams[row,1]}\t{testXParams[row,2]}\t{testXParams[row,3]}\t{testXParams[row,4]}\t{testXParams[row,5]}\t{testXParams[row,6]}\t{testXParams[row,7]}\t{classDict[predictions[row]]}\t{preds[row][0]}\t{preds[row][1]}\n")