-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscan.py
More file actions
35 lines (24 loc) · 996 Bytes
/
Copy pathscan.py
File metadata and controls
35 lines (24 loc) · 996 Bytes
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
from utilities import *
from keras.models import load_model
import numpy as np
autoencoder_model = load_model('./MODEL/autoencoder_model.h5')
#binary_data = pd.read_csv("./SAMPLES/wannacry_data/wannaCry.csv")
binary_data = pd.read_csv("./SAMPLES/benign_binary.csv")
print(binary_data)
binary_data = harmonize(binary_data)
print(binary_data)
reconstructed_binary_data = autoencoder_model.predict(binary_data)
binary_reconstruction_mse = np.mean(np.power(binary_data - reconstructed_binary_data, 2), axis=1)
with open("./MODEL/model_data.json", "r") as f:
data = json.load(f)
error=binary_reconstruction_mse.iloc[0]
threshold = data["threshold"]
confidence = 100-(1 - abs(error - threshold) / threshold) * 100
confidence=99 if confidence>100 else confidence
print("Threshold: {}".format(threshold))
print("Binary reconstruction error: {}".format(error))
if error<=threshold:
print('Verdict: Malware')
else:
print('Verdict: Benign')
print("Confidence:{} %".format(confidence))