def get_phone_data(speeches): feats = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feat = f.get_phone_features() feats.append(np.array(feat)) return feats
def get_word_overlap_data(speeches): feats = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feat = [f.get_n_common_words()] feats.append(np.array(feat)) return feats
def get_substring_data(speeches): feats = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feat = f.get_common_substring_features() feats.append(np.array(feat)) return feats
def get_audio_data(speeches): feats = [] for s in tqdm(speeches): s.phrase_audio_features = s.get_phrase_audio_features() f = featurizer.Featurizer(s) feat = f.get_audio_features() feats.append(np.array(feat)) return feats
def get_mean_vector_data(speeches): feats = [] labs = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feats.append(f.get_mean_vector_features()) labs.append(f.get_binary_labels()) return feats, labs
def train(self, train_data): f = featurizer.Featurizer(self.params) print "SELECTING FEATURES" f.select_features(train_data) print "FEATURIZING TRAIN SET" x = f.featurize(train_data) y = utils.get_labels_from_post_list(train_data) print "TRAINING MODEL" self.model.fit(x, y) self.f = f print "TRAINING CLASSIFICATION REPORT" test_classification = self.model.predict(x) print classification_report(test_classification, y)
def traverse(l, path1, path2): f = featurizer.Featurizer('vgg13') worker = mp.current_process() print('Traversing with ' + worker.name) participants = os.listdir(path1) #participants = ['p18', 'p19', 'p20', 'p21', 'p22', 'p23', 'p24'] for participant in participants: part_path = os.path.join(path1, participant) trials = os.listdir(part_path) for trial in trials: trial_path = os.path.join(part_path, trial) l.acquire() if is_locked(trial_path): print(trial_path + ' was locked. Moving on.') l.release() continue else: print('Locking ' + trial_path) lock(trial_path) l.release() feat_path = os.path.join(path2, participant, trial) print('Working on ' + trial_path + ' with ' + worker.name) os.system('mkdir -p ' + feat_path) frames = get_frames(trial_path) batches = get_batches(frames) num = 1 while True: try: batch = batches.next() except StopIteration: break print(worker.name + ' is doing a forward pass') t1 = time.time() batch_features = f.forward(ag.Variable(batch, volatile=True)) save_batch_features(feat_path, '{:05d}.t7'.format(num), batch_features) print(worker.name + ' {:.2f}'.format(time.time()-t1) + ' seconds to complete forward pass') num+=1
def get_vector_cosine_distance_data(speeches): feats = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feats.append(f.get_vector_cosine_distances()) return feats
def get_rst_data(speeches): feats = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) feats.append(f.get_rst_features()) return feats
def get_binary_labels(speeches): labs = [] for s in tqdm(speeches): f = featurizer.Featurizer(s) labs.append(f.get_binary_labels()) return labs
def wrapper(): window, fts = feat_func() return { 'WINDOW': window, 'FEATS': featurizer.Featurizer(types=fts, window=window), }