# Merging Two Intrusion Detection Systems


## Description

The "Merging Two Intrusion Detection Systems" project aims to improve the accuracy and reliability of intrusion detection by merging two existing intrusion detection systems. By combining the strengths of both systems, we strive to create a more robust and effective model that enhances cybersecurity and ensures better protection against potential threats.

## Purpose

The primary purpose of this project is to:

- Increase Detection Accuracy: By merging two intrusion detection systems, we aim to leverage their complementary strengths, leading to a higher overall accuracy in detecting and preventing intrusion attempts.

- Enhance Robustness: A merged intrusion detection system can be more resilient to various evasion techniques and adapt better to emerging threats, making it a more robust defense mechanism.

- Improve Cybersecurity: Strengthening intrusion detection is crucial in maintaining the integrity and security of systems and networks, safeguarding sensitive data from unauthorized access and attacks.

## Installation

To use the merged intrusion detection system, follow these installation steps:

1. **Prerequisites**: PyChar (Preferred) and some libraries like pandas, numpy, matplotlib, scikit-learn and keras which will be shown how to download during the
   installation process.

Setup Instructions
To run the "Merging Two Intrusion Detection Systems" project and evaluate the accuracy of the merged intrusion detection model, follow these steps:


bash
Copy code
git clone https://github.com/your-username/merging-intrusion-detection.git](https://github.com/ipoizzen/Merge-of-Two-Intrusion-Detection-Systems.git
1. Install Dependencies
Ensure you have the required dependencies installed. You can use pip to install them:

bash
Copy code
pip install pandas numpy matplotlib scikit-learn keras
2. Download the Trained Models
Download the pre-trained models (dnn3layer_model.hdf5 and test_model.hdf5) and place them in the kddresults/ directory of your local repository. You can get the models from the respective sources:

dnn3layer_model.hdf5: Download Link
test_model.hdf5: Download Link
3. Download the Testing Dataset
Download the testing dataset for evaluation. The dataset should be in CSV format and contain the features and labels. Place the CSV file in the root directory of your local repository.

You can get the testing dataset from the following link: https://figshare.com/ndownloader/files/5976042 and (https://raw.githubusercontent.com/rahulvigneswaran/Intrusion-Detection-Systems/master/dnn/kdd/binary/Testing.csv)

Download Testing Dataset

4. Run the Evaluation Script
Run the Python evaluation script evaluation_script.py, which performs the following tasks:

Loads the trained models.
Loads the testing dataset.
Prepares the dataset for evaluation.
Scales the input features.
Merges the models with different weight combinations to find the best accuracy.
Trains the callback model and records accuracy during training using early stopping.
Saves the accuracy history to a NumPy file.
Prints the best accuracy during training and the final accuracy on the test set.
Prints the classification report.
Plots the accuracy history during training.
bash
Copy code
python evaluation_script.py

5. View the Results
After running the evaluation script, you can find the following results:

best_accuracy.txt: This file contains the best accuracy achieved during training with the chosen weight combination.
kddresults/testing/accuracy_history.npy: A NumPy file storing the accuracy history during training (train and validation accuracy).
The evaluation script will also print the best weight combination for merging the models, the final accuracy on the test set, and the classification report.

6. Customize and Experiment
Feel free to customize the evaluation script and experiment with different weight combinations for merging the models. You can adjust the number of epochs for training, batch size, and other hyperparameters based on your requirements.

If you encounter any issues or have questions, please refer to the "Contributing" section in the README.md file to learn how to report issues or contribute to the project.

