Skip to content

Commit 559996e

Browse files
committed
Remove UNSW_NB15 load. Has not been used (yet)
Signed-off-by: Álvaro Bacca Peña <[email protected]>
1 parent 117abad commit 559996e

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

tests/test_utils.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import numpy as np
2424
import tensorflow as tf
2525

26-
from art.utils import projection, random_sphere, uniform_sample_from_sphere_or_ball, to_categorical, least_likely_class, \
27-
load_unsw_nb15
26+
from art.utils import projection, random_sphere, uniform_sample_from_sphere_or_ball, to_categorical, least_likely_class
2827
from art.utils import load_dataset, load_iris, load_mnist, load_nursery, load_cifar10
2928
from art.utils import second_most_likely_class, random_targets, get_label_conf, get_labels_np_array, preprocess
3029
from art.utils import compute_success_array, compute_success, check_and_transform_label_format
@@ -470,68 +469,6 @@ def test_nursery(self):
470469
self.assertEqual(x_train.shape[0], y_train.shape[0])
471470
self.assertEqual(x_test.shape[0], y_test.shape[0])
472471

473-
# FIXME: 52 secs to run. Its too long. Mock the web result with a subsample of the data
474-
def test_load_unsw_nb15_full(self):
475-
"""Test loading the full dataset with frac=1.0 (default)."""
476-
(x_train, y_train), (x_test, y_test) = load_unsw_nb15()
477-
478-
# size validation
479-
total_samples = 2_540_047 # FIXME: official sources say there are 2_540_044, but I counted in Excel
480-
self.assertEqual(x_train.shape[0] + x_test.shape[0], total_samples)
481-
self.assertEqual(len(y_train) + len(y_test), total_samples)
482-
self.assertEqual(x_train.shape[0], len(y_train))
483-
self.assertEqual(x_test.shape[0], len(x_test))
484-
485-
486-
def test_load_unsw_nb15_frac(self):
487-
"""Test loading the full dataset with frac=0.1"""
488-
(x_train, y_train), (x_test, y_test) = load_unsw_nb15(frac=0.1)
489-
490-
# size validation
491-
total_samples = 254_005
492-
self.assertEqual(x_train.shape[0] + x_test.shape[0], total_samples)
493-
self.assertEqual(len(y_train) + len(y_test), total_samples)
494-
self.assertEqual(x_train.shape[0], len(y_train))
495-
self.assertEqual(x_test.shape[0], len(x_test))
496-
497-
498-
# y has column 'attack_cat'
499-
self.assertIn("label", y_train.columns,
500-
"Column 'label' is missing from y_train")
501-
self.assertIn("label", y_test.columns,
502-
"Column 'label' is missing from y_test")
503-
504-
# x doesn't have the column 'attack_cat'
505-
self.assertNotIn("label", x_train.columns,
506-
"Column 'label' should not be in x_train")
507-
self.assertNotIn("label", x_test.columns,
508-
"Column 'label' should not be in y_train")
509-
510-
# feature count is correct (total 49)
511-
self.assertEqual(49 - 2, len(x_train.columns),
512-
"x_train doesn't have the 47 corresponding features")
513-
self.assertEqual(49 - 2, len(x_test.columns),
514-
"x_test doesn't have the 47 corresponding features")
515-
self.assertEqual(49 - 48, len(y_train.columns),
516-
"y_train doesn't have the single corresponding features")
517-
self.assertEqual(49 - 48, len(y_test.columns),
518-
"y_test doesn't have the single corresponding features")
519-
520-
# test column types
521-
actual_dtypes = x_train.dtypes.astype(str).value_counts().to_dict()
522-
523-
expected_dtypes = {
524-
'float64': 10,
525-
'int64': 30, # -1 porque es el label
526-
'object': 7, # -1 porque ID es removido
527-
}
528-
529-
for dtype, count in expected_dtypes.items():
530-
self.assertEqual(count,
531-
actual_dtypes.get(dtype, 0),
532-
f"Expected {count} columns of type {dtype}, but found {actual_dtypes.get(dtype, 0)}")
533-
534-
535472
def test_segment_by_class(self):
536473
data = np.array([[3, 2], [9, 2], [4, 0], [9, 0]])
537474
classes = to_categorical(np.array([2, 1, 0, 1]))

0 commit comments

Comments
 (0)