model = Model(GetCurrentPath() + '/Models/ProbabilityTables.pkl')    
    model.read()        

    [faces, nonfaces] = LoadData(GetCurrentPath() + '/Data/CalTech/test/faces/', \
                                 GetCurrentPath() + '/Data/CalTech/test/non-faces/', \
                                 model)
                                  
    
#    faces = [[1,1,0,1],[1,0,1,1],[1,1,1,1]]
#    nonfaces = [[1,1,1,0],[0,1,0,1],[0,1,1,0]]
#    faces = np.array(faces).T
#    nonfaces = np.array(nonfaces).T 
    
    classifier = SemiNaive(faces.shape[0], model.getNumCutOffs(), model.getSubgroupSize())   
    classifier.loadModel(model)
    likelihoodClass1 = classifier.test(faces)
    print '------------------------------------'
    likelihoodClass2 = classifier.test(nonfaces)
    
    TP = TP1 = TP2 = 0
    FP = 0
    Threshold = 0
    with open("Output.txt", "w") as output_file:
        for i in range(0,likelihoodClass1.shape[0]):
            output_file.write("%d %f\n" % (1, likelihoodClass1[i]))
            if (likelihoodClass1[i] >= Threshold): TP1 += 1
            else: FP += 1
           
        for i in range(0,likelihoodClass2.shape[0]):
    return quantizedFaceData, quantizedNonFaceData, cutoffs


############### main function #################
if __name__ == '__main__':
    SetupPath()
    from ReadDataSet import *
    from Quantization import *
    from SemiNaive import *
    from Model import *
    import settings

    settings.init()

    [faces, nonfaces, cutoffs] = LoadData(GetCurrentPath() + '/Data/CalTech/train/faces/', \
                                 GetCurrentPath() + '/Data/CalTech/train/non-faces/')

    model = Model(GetCurrentPath() + '/Models/ProbabilityTables.pkl')
    model.setCutOffs(cutoffs)

    #    faces = [[1,1,0,1],[1,0,1,1]]
    #    nonfaces = [[1,1,1,0],[0,1,0,1]]
    #    faces = np.array(faces).T
    #    nonfaces = np.array(nonfaces).T

    classifier = SemiNaive(faces.shape[0], settings.NUM_CUTOFF,
                           settings.SUBGROUP_SIZE)
    classifier.train(faces, nonfaces, model)

    del faces
    del nonfaces
    from SemiNaive import *
    from Model import *

    model = Model(GetCurrentPath() + '/Models/ProbabilityTables.pkl')
    model.read()

    [faces, nonfaces] = LoadData(GetCurrentPath() + '/Data/CalTech/test/faces/', \
                                 GetCurrentPath() + '/Data/CalTech/test/non-faces/', \
                                 model)

    #    faces = [[1,1,0,1],[1,0,1,1],[1,1,1,1]]
    #    nonfaces = [[1,1,1,0],[0,1,0,1],[0,1,1,0]]
    #    faces = np.array(faces).T
    #    nonfaces = np.array(nonfaces).T

    classifier = SemiNaive(faces.shape[0], model.getNumCutOffs(),
                           model.getSubgroupSize())
    classifier.loadModel(model)
    likelihoodClass1 = classifier.test(faces)
    print '------------------------------------'
    likelihoodClass2 = classifier.test(nonfaces)

    TP = TP1 = TP2 = 0
    FP = 0
    Threshold = 0
    with open("Output.txt", "w") as output_file:
        for i in range(0, likelihoodClass1.shape[0]):
            output_file.write("%d %f\n" % (1, likelihoodClass1[i]))
            if (likelihoodClass1[i] >= Threshold): TP1 += 1
            else: FP += 1

        for i in range(0, likelihoodClass2.shape[0]):
if __name__ == '__main__':  
    SetupPath()
    from ReadDataSet import *
    from Quantization import *
    from SemiNaive import *
    from Model import *
    import settings 
    
    settings.init()
    
    [faces, nonfaces, cutoffs] = LoadData(GetCurrentPath() + '/Data/CalTech/train/faces/', \
                                 GetCurrentPath() + '/Data/CalTech/train/non-faces/')
    
    model = Model(GetCurrentPath() + '/Models/ProbabilityTables.pkl')    
    model.setCutOffs(cutoffs)

    #print faces
    #print faces.shape[0]

    
#    faces = [[1,1,0,1],[1,0,1,1]]
#    nonfaces = [[1,1,1,0],[0,1,0,1]]
#    faces = np.array(faces).T
#    nonfaces = np.array(nonfaces).T      
    
    classifier = SemiNaive(faces.shape[0], settings.NUM_CUTOFF, settings.SUBGROUP_SIZE)    
    classifier.train(faces, nonfaces, model)
    #model.write()
    
    del faces
    del nonfaces