-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_path.py
28 lines (24 loc) · 894 Bytes
/
file_path.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
import sys
from pathlib import Path
import pandas as pd
import numpy as np
_data_dir = Path(__file__).parent
docs_path = {'original_data': _data_dir / 'final_{}.csv',
'embeding_matrix': _data_dir / 'embedding_x_{}.npy',
'process_y': _data_dir / 'process_y.npy',
'idcard_json': _data_dir / 'idcard_json.json',
'model_path': _data_dir / 'model_{}.h5'}
def load_file(data_name, tail=False):
file_path = str(docs_path[data_name])
if tail:
file_path = file_path.format(tail)
if file_path.endswith('npy'):
return np.load(file_path)
elif file_path.endswith('csv'):
return pd.read_csv(file_path)
else:
print('please check the {} name'.format(data_name))
if __name__ == '__main__':
tail = 'LOAN'
X = load_file('embeding_matrix', tail=tail)
print(X.shape)