def buildDataset(filenames, history=2, # how many snapshots into the past? ): D = SupervisedDataSet(set_feats + history * snap_feats, num_targ) for fname in filenames: rundata = quickload(fname) snapshots = rundata['snapshots'] settings = rundata['setting'] for i in range(len(snapshots) - history - 1): inp = parseFeatures(settings, snapshots[i:i + history]) prevtarget = parseTarget(snapshots[i + history-1]) nexttarget = parseTarget(snapshots[i + history]) # percentage gain target = (-nexttarget+prevtarget)/(nexttarget+prevtarget)/2. D.addSample(inp, [target]) return D
def inspect1(): for f in sorted(getAllFilesIn(logdir)[:60]): print f x = quickload(f) print len(x), type(x) for i, (k, v) in enumerate(x.items()): print i, k, type(v) for k, v in x['setting'].items(): print k for k, vv in v.items(): print ' ', k, vv print for i, sn in enumerate(x['snapshots']): print i for k, v in sn.items(): if k != 'weights': print '\t', k, v break
def readAndStore(): D = None try: D = quickload(ds_file) except Exception, e: print 'Oh-oh', e