os.path.isfile('{}/{}.{}'.format(trg_dir, trainingset_sample_indices_file, trainingset_suffix)): if override: print 'WARNING: The target directory {}/ already contains at least on of the files to create. Replacing.'.format(trg_dir) else: print 'WARNING: The target directory {}/ already contains at least on of the files to create. Skipping.'.format(trg_dir) sys.exit(1) # initializing collections training_set_selections = dict.fromkeys(training_set_cases) # iterate over cases, load their respective samples and perform a sampling for each # draw random stratified sample and extract training set indices sss = StratifiedShuffleSplit(classes, n_iter=1, train_size=n_samples) sample_indices, _ = sss.next() # save def load_feature_struct(f): "Load the feature struct from a feature config file." d, m = os.path.split(os.path.splitext(f)[0]) f, filename, desc = imp.find_module(m, [d]) return imp.load_module(m, f, filename, desc).features_to_extract def load_feature_names(f): "Load the feature names from a feature config file." fs = load_feature_struct(f) return [feature_struct_entry_to_name(e) for e in fs] if __name__ == "__main__":