def gather_features(feature_names, outpaths, subsample_rate): #=====[ Step 1: Sanitize input ]===== if not len(feature_names) == len(outpaths): click.echo("Make sure there is exactly one outpath for each feature") #=====[ Step 1: Connect to db ]===== click.echo("---> Connecting to DB") db = ModalDB() #=====[ Step 2: Gather features ]===== click.echo("---> Gathering features") feature_lists = {k:[] for k in feature_names} for frame in db.iter_frames(verbose=True, subsample_rate=subsample_rate): if not any([f[k] is None for k in feature_names]): for k in feature_names: feature_lists[k].append(frame[k]) #=====[ Step 3: Store gathered features ]===== click.echo("---> Storing gathered features") feature_matrices = {k:np.matrix(v) for k,v in feature_lists.items()} for name, path in zip(feature_names, outpaths): np.save(path, feature_names[name])
def gather_features(feature_names, outpaths, subsample_rate): #=====[ Step 1: Sanitize input ]===== if not len(feature_names) == len(outpaths): click.echo("Make sure there is exactly one outpath for each feature") #=====[ Step 1: Connect to db ]===== click.echo("---> Connecting to DB") db = ModalDB() #=====[ Step 2: Gather features ]===== click.echo("---> Gathering features") feature_lists = {k: [] for k in feature_names} for frame in db.iter_frames(verbose=True, subsample_rate=subsample_rate): if not any([f[k] is None for k in feature_names]): for k in feature_names: feature_lists[k].append(frame[k]) #=====[ Step 3: Store gathered features ]===== click.echo("---> Storing gathered features") feature_matrices = {k: np.matrix(v) for k, v in feature_lists.items()} for name, path in zip(feature_names, outpaths): np.save(path, feature_names[name])
def show_schema(): db = ModalDB() print '==========[ Current Schema ]==========' db.print_schema()