-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdimensionality_reduction_directory.py
30 lines (22 loc) · 1.18 KB
/
dimensionality_reduction_directory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import os
from utils import printTrace, get_dimensions
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--directory', type=str)
parser.add_argument('-o', '--output_directory', type=str)
parser.add_argument('-m', '--method', choices=['PCA', 'tSVD', 'DRA'], default='DRA')
parser.add_argument('-n', '--reduce_to', type=int, default=300)
parser.add_argument('-b', '--do_in_batches', action='store_true')
args = parser.parse_args()
files = [os.path.join(args.directory, f) for f in os.listdir(args.directory) if
os.path.isfile(os.path.join(args.directory, f))]
for i_file, file in enumerate(files):
printTrace('Dimensionality reduction: Embedding ' + str(i_file) + ' of ' + str(len(files)) + ' : ' + str(file))
excec_com = 'python3 dimensionality_reduction.py -i ' + str(file) + ' -m ' + str(args.method) + ' -o ' +\
args.output_directory + file.split('/')[-1] + '_' + str(args.method) +'.vec -n ' +\
str(args.reduce_to) + (' -b ' if args.do_in_batches else '')
print(excec_com)
os.system(excec_com)
if __name__ == '__main__':
main()