Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.pad.base
Commits
9ddf3309
Commit
9ddf3309
authored
Jun 22, 2018
by
Guillaume HEUSCH
Browse files
[utils] added some debug stuff
parent
5675f218
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/pad/base/utils/helper_functions.py
View file @
9ddf3309
...
...
@@ -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.
real
=
convert_and_prepare_features
(
training_features
[
0
])
# output is array
# training_features[1] - training features for the ATTACK class.
attack
=
convert_and_prepare_features
(
training_features
[
1
])
# output is array
# uniformly select subsets of features:
real_subset
=
select_uniform_data_subset
(
real
,
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
)
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment