-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_engineering.py
54 lines (44 loc) · 1.25 KB
/
feature_engineering.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author : Insup Lee <islee94@korea.ac.kr>
# April 2020
import os
import time
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from data_tlsdnshttp import TlsDnsHttp
def get_colors(t):
color_dict = {0: "#0392cf", 1: "#7bc043", 2: "#ee4035"}
colors = list()
for i in range(len(t)):
colors.append(color_dict[t[i]])
return np.array(colors)
def main():
tdh = TlsDnsHttp()
X, y = tdh.get_data()
do_plot = False
if do_plot:
colors = get_colors(y)
pd.plotting.scatter_matrix(X, color=colors, diagonal='kde')
print(X.shape)
print(X['interarrival_time'])
print(X['frame_time'])
return
for i in range(4):
start_idx = i*8
last_idx = (i+1)*8
if i == 3:
last_idx -= 1
X_temp = X.iloc[:, list(range(start_idx, last_idx))]
X_temp.boxplot()
plt.show()
with open(os.path.join("result_feature-engineering", "describe.txt"), "wt") as wf:
wf.write(str(X.describe()))
#print(X.describe())
if __name__ == "__main__":
print("HELLO MAIN")
start_time = time.time()
main()
print("[!] time {:.3f} seconds".format(time.time() - start_time))
print("END")