forked from Superzchen/iLearn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiLearn-feature-normalization.py
24 lines (20 loc) · 1.15 KB
/
iLearn-feature-normalization.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
#!/usr/bin/env python
#_*_coding:utf-8_*_
import argparse
from featurenormalization import *
from pubscripts import read_code, save_file
if __name__ == '__main__':
parser = argparse.ArgumentParser(usage="it's usage tip.",
description="feature vector normalization")
parser.add_argument("--file", required=True, help="input encoding file format")
parser.add_argument("--format", choices=['csv', 'tsv', 'svm', 'weka'], default='svm',
help="the encoding type")
parser.add_argument("--method", required=True,
choices=['ZScore', 'MinMax'], help="select feature normalization method")
parser.add_argument("--out", default="normalized_features.txt", help="file with normalized features vectors")
args = parser.parse_args()
encodings, labels = read_code.read_code(args.file, format=args.format)
cmd = args.method + '.' + args.method + '(encodings, labels)'
print('Feature normalization method: ' + args.method)
normalized_feature_vectors, e = eval(cmd)
save_file.save_file(normalized_feature_vectors, args.format, args.out)