text_plain_output_1.png
from sklearn.model_selection import train_test_split

from sklearn.preprocessing import MinMaxScaler

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_parquet('/kaggle/input/sampled-datasets-v2/NF-UNSW-NB15-V2.parquet')
columns_to_remove = ['L4_SRC_PORT', 'L4_DST_PORT', 'Label', 'Attack']
train, test = train_test_split(df, test_size=0.2, shuffle=True)
y_test = np.array(test['Label'], dtype=np.uint8)
train_benign_idx = train['Label'] == 0
train_attack_idx = train['Label'] == 1
train.drop(columns=columns_to_remove, axis=1, inplace=True)
test.drop(columns=columns_to_remove, axis=1, inplace=True)
train_normal = train[train_benign_idx].values
train_attack = train[train_attack_idx].values
scaler = MinMaxScaler()
train = scaler.fit_transform(train_normal)
train_attack = scaler.transform(train_attack)
train, validation = train_test_split(train, test_size=0.2)
print(f'Shape train data: {train.shape}')
print(f'Shape validation data: {validation.shape}')
print(f'Shape test data: {test.shape}')