Commit 9ddf3309 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[utils] added some debug stuff

parent 5675f218
...@@ -473,16 +473,30 @@ def prepare_data_for_hyper_param_grid_search(training_features, n_samples): ...@@ -473,16 +473,30 @@ def prepare_data_for_hyper_param_grid_search(training_features, n_samples):
# training_features[0] - training features for the REAL class. # training_features[0] - training features for the REAL class.
real = convert_and_prepare_features( real = convert_and_prepare_features(
training_features[0]) # output is array training_features[0]) # output is array
# training_features[1] - training features for the ATTACK class. # training_features[1] - training features for the ATTACK class.
attack = convert_and_prepare_features( attack = convert_and_prepare_features(
training_features[1]) # output is array training_features[1]) # output is array
# uniformly select subsets of features:
real_subset = select_uniform_data_subset(real, n_samples) real_subset = select_uniform_data_subset(real, n_samples)
attack_subset = select_uniform_data_subset(attack, n_samples) attack_subset = select_uniform_data_subset(attack, n_samples)
# split the data into train and cross-validation:
real_train, real_cv = split_data_to_train_cv(real_subset) real_train, real_cv = split_data_to_train_cv(real_subset)
attack_train, attack_cv = split_data_to_train_cv(attack_subset) attack_train, attack_cv = split_data_to_train_cv(attack_subset)
# basically, convert to numpy array and splits real and attacks in two sets of equal size ...
# 1st half of examples are for training, 2nd half are for cross-validation
# WARNING: this is because the provided n_samples is greater that the number of features for each class
n_real = np.array(training_features[0]).shape[0]
n_attack = np.array(training_features[1]).shape[0]
if np.all(np.array(training_features[0][:np.int(n_real/2)]) == real_train):
print("real train is equal to the first half of training_features[0]")
if np.all(np.array(training_features[1][:np.int(n_attack/2)]) == attack_train):
print("attack train is equal to the first half of training_features[1]")
if np.all(np.array(training_features[0][np.int(n_real/2):2*np.int(n_real/2)+1]) == real_cv):
print("real cv is equal to the second half of training_features[0]")
if np.all(np.array(training_features[1][np.int(n_attack/2):2*np.int(n_attack/2)+1]) == attack_cv):
print("attack cv is equal to the second half of training_features[1]")
return real_train, real_cv, attack_train, attack_cv return real_train, real_cv, attack_train, attack_cv
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment