forked from abshinn/higgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsavetonumpy.py
More file actions
executable file
·51 lines (37 loc) · 1.12 KB
/
Copy pathsavetonumpy.py
File metadata and controls
executable file
·51 lines (37 loc) · 1.12 KB
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
#!/usr/bin/env python2.7
import numpy as np
import pandas as pd
import pdb
import sys
traindf = pd.read_csv("training.csv")
# testdf = pd.read_csv("test.csv")
pdb.set_trace()
# print("sample size: {}".format(len(traindf)))
# sampleindex = traindf.pop(u"Unnamed: 0")
cpubusy = traindf.pop("cpu_01_busy")
y = np.mat(cpubusy.values).T
#
# work on features
#
m = y.shape[0]
label = traindf.pop("Label")
label[np.where(label == "s")] = 1
label[np.where(label == "b")] = 0
# binarization of server id
# m_id_dummy = pd.get_dummies(m_id).values[:,1:]
# turn time into integer
dttime = pd.to_datetime(traindf.pop("sample_time"))
inttime = dttime.astype(np.int64)
# del traindf["syst_page_read_ipo_rate"]
# del traindf["page_global_valid_fault_rate"]
# X = np.mat(np.c_[np.ones(m), traindf.values, m_id_dummy, inttime])
X = np.mat(np.c_[traindf.values, m_id_dummy, inttime])
X = X.astype(np.float64)
y = y.astype(np.float64)
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == "-s":
np.save("X.npy", X)
np.save("Y.npy", y)
print("Output written:\nX.npy\nY.npy")
else:
print("no output")