-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathPreprocessing.py
27 lines (23 loc) · 1.01 KB
/
Preprocessing.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
from io import open
from Variable import *
from Mongo_Con import *
def transform_type(input_file, output_file):
with open(output_file, "w") as text_file:
with open(input_file) as f:
lines = f.readlines()
for line in lines:
columns = line.split(',')
for raw_type in category:
flag = False
if raw_type == columns[-1].replace("\n", ""):
str = ','.join(columns[0:attr_list.index('type')])
text_file.write("%s,%d\n" % (str, category[raw_type]))
flag = True
break
if not flag:
text_file.write(line)
print(line)
transform_type("raw/kddcup.data_10_percent.txt", "data/kddcup.data_10_percent.txt")
transform_type("raw/corrected.txt", "data/corrected.txt")
DB_manager().import_training_data("data/kddcup.data_10_percent.txt")
DB_manager().import_test_data('data/corrected.txt')