-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_input.py
32 lines (23 loc) · 1.11 KB
/
create_input.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
import sys
import numpy as np
import utils.utilsgeo as ug
from scipy.spatial import distance
def create_input(argv):
locate_dataset = sys.argv[1]
k = sys.argv[2]
X_train = np.load(locate_dataset + 'X_train.npy', allow_pickle=True)
X_test = np.load(locate_dataset + 'X_test.npy', allow_pickle=True)
y_train = np.load(locate_dataset + 'y_train.npy', allow_pickle=True)
y_test = np.load(locate_dataset + 'y_test.npy', allow_pickle=True)
idx, dist = ug.create_sequence(X_train, X_test, int(k))
idx_eucli, dist_eucli = ug.recovery_dist(idx[:X_train.shape[0], :],
idx[X_train.shape[0]:, :], X_train[:, 2:],
X_test[:, 2:], distance.euclidean)
idx_geo = idx
dist_geo = dist
idx_eucli = idx_eucli
dist_eucli = dist_eucli
np.savez_compressed(locate_dataset + 'data.npz', dist_eucli=dist_eucli, dist_geo=dist_geo, idx_eucli=idx_eucli,
idx_geo=idx_geo, X_test=X_test, X_train=X_train, y_test=y_test, y_train=y_train)
if __name__ == '__main__':
create_input(sys.argv[1:])