-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_datasets.py
66 lines (63 loc) · 2.69 KB
/
build_datasets.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from preprocess_mimic import process_mimic
from vectorize_data import process_data
from preprocess_final import preprocess
import os
import sys
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == 'aws':
file_notes = 's3://dl4h-ksi/data/NOTEEVENTS.csv'
file_diagnoses = 's3://dl4h-ksi/data/DIAGNOSES_ICD.csv'
else:
file_notes = 'data/NOTEEVENTS.csv'
file_diagnoses = 'data/DIAGNOSES_ICD.csv'
process_mimic(file_notes=file_notes,
file_diagnoses=file_diagnoses,
word_threshold=10,
code_freq_threshold=0,
output_file='data/combined_dataset')
# original dataset from paper
file_wiki = 'data/wikipedia_knowledge'
subdir = 'original/'
os.makedirs(f'data/{subdir}', exist_ok=True)
process_data(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
output_wiki=f'data/{subdir}wikivec',
output_mimic=f'data/{subdir}notevec',
vectorizer_type='binary')
preprocess(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
file_wikivec=f'data/{subdir}wikivec.npy',
file_notevec=f'data/{subdir}notevec.npy',
out_dir=f'data/{subdir}',
original=True,
vectorizer_type='binary')
# original dataset from paper, normalized word frequencies
subdir = 'original_freqs/'
os.makedirs(f'data/{subdir}', exist_ok=True)
process_data(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
output_wiki=f'data/{subdir}wikivec',
output_mimic=f'data/{subdir}notevec',
vectorizer_type='count')
preprocess(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
file_wikivec=f'data/{subdir}wikivec.npy',
file_notevec=f'data/{subdir}notevec.npy',
out_dir=f'data/{subdir}',
original=False,
vectorizer_type='count')
# original dataset from paper, tfidf
subdir = 'original_tfidf/'
os.makedirs(f'data/{subdir}', exist_ok=True)
process_data(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
output_wiki=f'data/{subdir}wikivec',
output_mimic=f'data/{subdir}notevec',
vectorizer_type='tfidf')
preprocess(file_wiki=file_wiki,
file_mimic='data/combined_dataset',
file_wikivec=f'data/{subdir}wikivec.npy',
file_notevec=f'data/{subdir}notevec.npy',
out_dir=f'data/{subdir}',
original=False,
vectorizer_type='tfidf')