/
ANN_doWork.py
31 lines (31 loc) · 1.1 KB
/
ANN_doWork.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
import NetFlow_ANN
import preprocessdump
import sys, os, getopt
from collections import OrderedDict
def loader(argv=sys.argv):
try:
opts, args= getopt.getopt(sys.argv[1:],"h",["help"])
except getopt.error, msg:
print msg
print "for help use --help"
sys.exit(2)
for o, a in opts:
if o in ("-h","--help"):
print "there is no damn help"
sys.exit(0)
#paras: processed_dumpfile limit outputfile
ANN=NetFlow_ANN.NetFlow_ANN()
ANN.set_datasource(preprocessdump.datasource(args[0]))
ANN.normalize_base=ANN.data_source.load_base_from_file(args[0])
input=ANN.data_source.load_dump_from_file(args[0]+'_sus')
input.extend(ANN.data_source.load_dump_from_file(args[0]+'_non_sus'))
result=ANN.classifier(input,args[1])
result=OrderedDict(sorted(result.items(), key=lambda t: t[1]))
items=result.items()
items.reverse()
result=OrderedDict(items)
outputfile=open(args[2],'w')
for key,value in result.items():
outputfile.write(str(key)+' : '+str(value)+'\n')
if __name__=='__main__':
sys.exit(loader())