def runLushWithPipes(scriptName, *arguments, **keywordArguments): # Initialize scriptPath = os.path.join(DIRECTORY, store.replaceFileExtension(scriptName, 'lsh')) terms = ['lush', scriptPath, DIRECTORY] + [str(x) for x in arguments] standardError = True errorCount = 0 errorLimit = 5 standardInput = keywordArguments.get('standardInput') # While there is standardError, while standardError: # Try again if standardInput: process = subprocess.Popen(terms, stdin=PIPE, stdout=PIPE, stderr=PIPE) standardOutput, standardError = process.communicate(standardInput) else: process = subprocess.Popen(terms, stdout=PIPE, stderr=PIPE) standardOutput, standardError = process.communicate() # If we have an error, if standardError: # Count errorCount += 1 print 'Failed (%d/%d): %s' % (errorCount, errorLimit, store.extractFileBaseName(scriptPath)) if errorCount >= errorLimit: raise ClassifierError(standardError) # Return return standardOutput
def getPaths(self, baseFolderName, folderName): 'Return a list of paths with the latest first' # Get paths baseFolderPath = self.folderPathByName[baseFolderName] folderPaths = glob.glob(os.path.join(baseFolderPath, '*-%s' % folderName)) # Sort by timestamp folderPacks = [(pattern_timestamp.match(store.extractFileBaseName(x)).group(1), x) for x in folderPaths] folderPacks.sort() folderPaths = [x[1] for x in reversed(folderPacks)] # Append fileNames return folderPaths
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 getPaths(self, baseFolderName, folderName): 'Return a list of paths with the latest first' # Get paths baseFolderPath = self.folderPathByName[baseFolderName] folderPaths = glob.glob( os.path.join(baseFolderPath, '*-%s' % folderName)) # Sort by timestamp folderPacks = [ (pattern_timestamp.match(store.extractFileBaseName(x)).group(1), x) for x in folderPaths ] folderPacks.sort() folderPaths = [x[1] for x in reversed(folderPacks)] # Append fileNames return folderPaths