def evaluate(classifierPath, testPath):
    # Evaluate whole
    actualLabels = classifier.loadLabels(testPath)
    predictedLabels = test(classifierPath, testPath)
    resultByName = evaluation_process.evaluateClassifier(actualLabels, predictedLabels, 'Boosted convolutional neural network')
    # Evaluate parts
    for weakClassifierPath in glob.glob(os.path.join(classifierPath, 'weak*.info')):
        weakName = store.extractFileBaseName(weakClassifierPath)
        weakClassifierInformation = store.loadInformation(weakClassifierPath)
        resultByName[weakName] = weakClassifierInformation['performance']
    # Return
    return resultByName
def saveSamples(sampleDataset, sampleIDs, featureSet):
    # Initialize
    sampleCount = len(sampleIDs)
    sampleDatasetPath = sampleDataset.getDatasetPath()
    sampleInformation = {
        'source dataset': {
            'path': sampleDatasetPath,
            'sample ids': ' '.join(str(x) for x in sampleIDs),
        },
        'feature': {
            'module name': featureSet.__module__,
            'class name': featureSet.__class__.__name__,
        }
    }
    targetSampleName = '%s-count%s-min%s' % (folder_store.getFolderName(sampleDatasetPath), sampleCount, min(sampleIDs))
    targetSamplePath = os.path.join(store.makeFolderSafely(os.path.join(store.temporaryPath, 'cnn_datasets')), targetSampleName)
    # If targetDatasetPath exists, return
    if store.loadInformation(targetSamplePath) == sampleInformation: 
        print 'Using existing samples...\n\ttargetSamplePath = ' + targetSamplePath
        return targetSamplePath
    # Save
    print 'Saving samples...\n\ttargetSamplePath = ' + targetSamplePath
    sampleGenerator = makeSampleLabelGeneratorFromSampleDataset(sampleDataset, sampleIDs, featureSet)
    sampleFile, labelFile = [open(x, 'wt') for x in makeSampleLabelPaths(targetSamplePath)]
    for sampleIndex, (sample, label) in enumerate(sampleGenerator): 
        # If we are starting, write header
        if sampleIndex == 0:
            sampleFile.write(makeLushMatrixHeaderFromPart(sample, sampleCount))
            labelFile.write(makeLushMatrixHeaderFromPart(label, sampleCount))
        # Write content
        sampleFile.write(makeLushMatrixContent(sample))
        labelFile.write(makeLushMatrixContent(label))
        if sampleIndex % 100 == 0: 
            view.printPercentUpdate(sampleIndex + 1, sampleCount)
    view.printPercentFinal(sampleCount)
    # Return
    labelFile.close(); sampleFile.close()
    store.saveInformation(targetSamplePath, sampleInformation)
    return targetSamplePath
 def __init__(self, informationPath):
     informationPath = os.path.join(os.path.dirname(informationPath), folder_store.fileNameByFolderName['patches'])
     self.information = store.loadInformation(informationPath)
 def __init__(self, informationPath):
     self.information = store.loadInformation(informationPath)
 def __init__(self, informationPath):
     self.information = store.loadInformation(informationPath)
 def __init__(self, informationPath):
     self.informationPath = informationPath
     self.information = store.loadInformation(informationPath)
     self.parameterByName = self.information['parameters']