This repo is largely influenced by the work of Yann Busnel and Léo Lavaur.
For now, we use UNSW-NB15 dataset in the folder ./dataset/UNSW-B15 available here.
- Python 3.9 (or higher?)
- pip
- virtualenv (if not included in python by default)
git clone [url]
cd IDS-Federated-Learning
python3.9 -m venv venv
source venv/bin/activate
pip install -r requirements.txtif you want to reprocess the UNSW-NB15 dataset, you can use the following command:
python src/preprocess.py --output hard_0.05_custom --hard --normal_frac 0.05
Args :
--output: name of the output folder--hard: use hard to restrict the dataset even more. Attack categories removed in hard mode are are : Dos. (In addtion to the normally removed : Analysis, Backdoors, Shellcode, Worms)--normal_frac: fraction of normal traffic in the dataset
All the simulation work with a config file in yaml format. You can find an example called 'config_example.yaml' in the root folder.
In this file, you can set all the parameters of the simulation. Please see the config_example.yaml file for more details.
To start the simulation, you can then use the following command:
python main.py --config config_example.yaml
If you want to specify the output folder you can use --output argument.
You can also specify to force the overwrite of the output folder with -f, and force the re-extraction of the dataset with -r (Otherwise, the data folder will be used if it exists).
The results of the simulation are stored in the output folder. (By default, the output folder is called with the config file name)
You can find the following files:
confusion_matrix.png: confusion matrix of the final global model (on the test set)metrics.json: metrics of the model for each class (on the test set)history.json: history of the training metrics for each roundhistory.png: plot of the history of the training metrics for each roundmodel.keras: model saved after the training
If you have the default Flwr version, please make sure that this argument in the main_fe.py file is commented:
metric_evaluation_target=METRIC_EVALUATION_TARGET,To clean the project, you can use make clean.
In the Makefile, you can find some other commands to bypass the config file, and lunch the src scripts directly. They may not work as expected.
This repo is still under development.