def run(inputFiles, networkConfigsFile, plotResults, runClustering): with open(networkConfigsFile, 'rb') as jsonFile: networkConfigurations = simplejson.load(jsonFile) expResults = [] for networkConfig in networkConfigurations: for inputFile in inputFiles: expResult = runExperiment(networkConfig, inputFile, runClustering) expResults.append(expResult) if plotResults: # traces = loadTraces(fileName) traces = expResult['expTrace'] tmParams = networkConfig['tmRegionConfig']['regionParams'] numCells = tmParams['cellsPerColumn'] * tmParams['inputWidth'] numClusters = len(set(traces['actualCategory'])) if os.path.exists(OUTPUT_DIR): shutil.rmtree(OUTPUT_DIR) os.makedirs(OUTPUT_DIR) cellsType = CELLS_TO_CLUSTER numSteps = len(traces['recordNumber']) pointsToPlot = numSteps / 10 vizInterCategoryClusters(traces, OUTPUT_DIR, cellsType, numCells, pointsToPlot) vizInterSequenceClusters(traces, OUTPUT_DIR, cellsType, numCells, numClusters) xl = None plotTemporalMemoryStates = False title = inputFile.split('/')[-1] outputFile = '%s.png' % inputFile[:-4] plotTraces(xl, traces, title, ANOMALY_SCORE, outputFile, runClustering) traceOutputDir = os.path.join(OUTPUT_DIR, 'traces') if not os.path.exists(traceOutputDir): os.makedirs(traceOutputDir) saveTraces(os.path.join(traceOutputDir, '%s.csv'), expResults)
def run(inputFiles, networkConfigsFile, plotResults, runClustering): with open(networkConfigsFile, 'rb') as jsonFile: networkConfigurations = simplejson.load(jsonFile) expResults = [] for networkConfig in networkConfigurations: for inputFile in inputFiles: expResult = runExperiment(networkConfig, inputFile, runClustering) expResults.append(expResult) if plotResults: # traces = loadTraces(fileName) traces = expResult['expTrace'] tmParams = networkConfig['tmRegionConfig']['regionParams'] numCells = tmParams['cellsPerColumn'] * tmParams['inputWidth'] numClusters = len(set(traces['actualCategory'])) if os.path.exists(OUTPUT_DIR): shutil.rmtree(OUTPUT_DIR) os.makedirs(OUTPUT_DIR) cellsType = CELLS_TO_CLUSTER numSteps = len(traces['recordNumber']) pointsToPlot = numSteps / 10 vizInterCategoryClusters(traces, OUTPUT_DIR, cellsType, numCells, pointsToPlot) vizInterSequenceClusters(traces, OUTPUT_DIR, cellsType, numCells, numClusters) xl = None plotTemporalMemoryStates = False title = inputFile.split('/')[-1] outputFile = '%s.png' % inputFile[:-4] plotTraces(xl, traces, title, outputFile, plotTemporalMemoryStates) traceOutputDir = os.path.join(OUTPUT_DIR, 'traces') if not os.path.exists(traceOutputDir): os.makedirs(traceOutputDir) saveTraces(os.path.join(traceOutputDir, '%s.csv'), expResults)
dest="numTmCells", help="Number of cells in the Temporal Memory") (options, remainder) = parser.parse_args() return options, remainder if __name__ == "__main__": (_options, _args) = _getArgs() inputFile = _options.fileName plotTemporalMemoryStates = _options.plotTemporalMemoryStates if _options.xl: xl = [int(x) for x in _options.xl.split(',')] else: xl = _options.xl print inputFile traces = loadTraces(inputFile) numTmCells = _options.numTmCells title = inputFile.split('/')[-1] outputFile = '%s.png' % inputFile[:-4] plt = plotTraces(xl, traces, title, ANOMALY_SCORE, outputFile, CLUSTERING, numTmCells, plotTemporalMemoryStates) plt.show()
default=None, dest="xl", help="x-axis range") parser.add_option("--numTmCells", type=int, default=32 * 2048, dest="numTmCells", help="Number of cells in the Temporal Memory") (options, remainder) = parser.parse_args() return options, remainder if __name__ == "__main__": (_options, _args) = _getArgs() fileName = _options.fileName if _options.xl: xl = [float(x) for x in _options.xl.split(',')] else: xl = _options.xl traces = loadTraces(fileName) title = fileName numTmCells = _options.numTmCells plotTraces(numTmCells, title, xl, traces)
default=32 * 2048, dest="numTmCells", help="Number of cells in the Temporal Memory") (options, remainder) = parser.parse_args() return options, remainder if __name__ == "__main__": (_options, _args) = _getArgs() inputFile = _options.fileName plotTemporalMemoryStates = _options.plotTemporalMemoryStates if _options.xl: xl = [int(x) for x in _options.xl.split(',')] else: xl = _options.xl print inputFile traces = loadTraces(inputFile) numTmCells = _options.numTmCells title = inputFile.split('/')[-1] outputFile = '%s.png' % inputFile[:-4] plotTraces(xl, traces, title, ANOMALY_SCORE, outputFile, numTmCells, plotTemporalMemoryStates)