-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMalware_Detection_Using_DeepLearning (1).py
More file actions
111 lines (54 loc) · 1.51 KB
/
Malware_Detection_Using_DeepLearning (1).py
File metadata and controls
111 lines (54 loc) · 1.51 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
# coding: utf-8
# In[56]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import classification_report
malData=pd.read_csv("MalwareData.csv",sep="|")
malData=malData.sample(frac=1).reset_index(drop=True)
dataset=malData.drop(["legitimate","Name","md5"],axis=1)
legitimate_col=malData["legitimate"]
# In[15]:
X_train=dataset[0:124242].to_numpy()
Y_train=legitimate_col[0:124242].to_numpy()
# In[16]:
X_test=dataset[124242::].to_numpy()
Y_test=legitimate_col[124242::].to_numpy()
# In[4]:
from keras.models import Sequential
from keras.layers import Dense
# In[49]:
model=Sequential()
model.add(Dense(100,input_dim=54,activation='relu'))
model.add(Dense(50,activation='relu'))
model.add(Dense(25,activation='relu'))
model.add(Dense(1,activation='sigmoid'))
print(model.summary())
# In[50]:
model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])
# In[51]:
history=model.fit(X_train,Y_train,epochs=30,batch_size=10000)
# In[52]:
losses=history.history['loss']
epochs=range(1,len(losses)+1)
plt.plot(epochs,losses)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.show()
# In[53]:
accuracy=history.history['accuracy']
plt.plot(epochs,accuracy)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.show()
# In[64]:
pred=model.predict(X_test)
pred_int=pred.astype(int)
#print(pred_int)
print(classification_report(Y_test,pred_int))
# In[65]:
_,accuracy =model.evaluate(X_test,Y_test)
print(accuracy)
# In[ ]:
# In[ ]: