15
15
from sklearn .model_selection import train_test_split
16
16
17
17
import joblib
18
+ import numpy as np
18
19
19
20
# This module is based on the implementation by Alessandro Erba, original is found here:
20
21
# https://github.com/scy-phy/ICS-Evasion-Attacks/blob/master/Adversarial_Attacks/Black_Box_Attack/adversarial_AE.py
@@ -81,12 +82,12 @@ def save_model(self, model_filename, scaler_filename):
81
82
82
83
def init_generator (self , training_path ):
83
84
# Load and preprocess training data
84
- training_path = Path (__file__ ).parent / training_path / 'training_data.csv'
85
+ #training_path = Path(__file__).parent/training_path/'training_data.csv'
86
+ training_path = Path (__file__ ).parent / training_path / 'ground_truth_dataset.csv'
85
87
# print('Reading training data from: ' + str(training_path))
86
88
self .physical_pd = self .preprocess_physical (training_path )
87
89
88
90
# Adversarial model for concealment
89
- # toDo: Ask about this parameter
90
91
hide_layers = 160
91
92
self .hide_layers = hide_layers
92
93
self .generator_layers = [self .feature_dims ,
@@ -129,14 +130,19 @@ def fix_sample(self, gen_examples):
129
130
return gen_examples
130
131
131
132
def predict (self , received_values_df ):
132
- print ('Attempting to predict concealment values' )
133
+ # print('Attempting to predict concealment values')
133
134
# print('Features received to predict: ' + str(received_values_df.columns))
134
135
# print('Features received to train: ' + str(self.sensor_cols))
135
136
136
137
gen_examples = self .generator .predict (self .attacker_scaler .transform (received_values_df ))
138
+ #print('nan predicted values: ')
139
+ # print(gen_examples)
140
+ #print(np.isnan(gen_examples))
137
141
gen_examples = self .fix_sample (pd .DataFrame (columns = self .sensor_cols ,
138
142
data = self .attacker_scaler .inverse_transform (gen_examples )))
139
143
144
+ #print('Model fixed values')
145
+ #print(gen_examples)
140
146
return gen_examples
141
147
142
148
def __init__ (self , features_list ):
@@ -145,3 +151,4 @@ def __init__(self, features_list):
145
151
self .sensor_cols = [col for col in features_list if
146
152
col not in ['Unnamed: 0' , 'iteration' , 'timestamp' , 'Attack' ]]
147
153
self .feature_dims = len (self .sensor_cols )
154
+ print (f'Model has { self .feature_dims } input features' )
0 commit comments