Support Vector Machine (SVM):
This is a supervised learning algorithm. It is used for regression, classification, and outlier detection tasks in classical machine learning. It is mainly effective for high-dimensional data. It is robust in solving linear and non-linear classification problems.
Quantum Support Vector Machine (QSVM):
It is an enhanced version of the Support Vector Machine (SVM). Used for classification and regression. In this quantum computing techniques are used to leverage the efficiency of classical SVM. Mainly, used when dealing with high-dimensional and complex data.
The above diagram is from: QuantumNetSec: Quantum Machine Learning for Network Security, Diego Abreu1, David Moura2, Christian Rothenberg2, and Antˆonio Abel´em1
About the Dataset:
Dataset link: Bank Account Fraud Dataset Suite (NeurIPS 2022)
The Bank Account Fraud (BAF) suite of datasets has been published at NeurIPS 2022.
This particular dataset is from Kagale. It is composed of 6 different datasets, one of which is the Base.csv dataset.
The fraud_bool is the Label and the rest of the columns are the features.
Installing Required libraries
Importing all the required packages
Mount Google Drive, so that you can access your files using the path '/content/drive', which corresponds to your Google Drive directory. You can combine it with os functions to list files, read data, and interact with your files stored in Drive. Define the path for the dataset. Then load the CSV file into the dataframe and handle the missing values.
Mounting the Google Drive and accessing the dataset from the Google Drive.
These are the steps to mount the Google Drive through code.
First Upload the dataset into the Drive and make note of the dataset path.
When you run the above code cell this particular pop-up will appear. Click "Connect to Google Drive".
Then select the Google Drive account in which the dataset is uploaded.
Select "Continue"
Select "Continue" and the drive will be mounted.
In our data preprocessing, we standardize all features, apply Principal Component Analysis (PCA) for transformation, normalize the transformed data, convert the target column to numerical values, and finally, split the dataset into training and testing subsets.
Training and evaluating the classical model.
This code initializes a two-qubit quantum device and defines a feature mapping circuit to encode classical data into quantum states. It utilizes Hadamard gates for superposition, RY rotations for feature encoding, and CNOT gates for entanglement. This quantum feature mapping enables enhanced pattern recognition in quantum machine learning tasks.
We created a quantum kernel to imitate the functionality of an SVM algorithm. Then compute the kernel matrix and computing them.
Training the QSVM model with the quantum kernel and predicting and printing the accuracies.
Plotting the graph for the accuracies of both the classical and quantum models.
Accuracies:
Link for the code: Code Link (Time took to run the code: 2 hrs)
Link for Dataset: Dataset Link