By the end of this guide you will have the FFD repository running locally, all dependencies installed, and the complete pipeline executing — from loading raw credit card transaction data all the way through GAN training, synthetic data generation, and evaluation of six fraud detection classifiers.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Antisource/FFD/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Python 3.8+ installed and available on your
PATH - pip for package installation
- Git to clone the repository
- Jupyter to run the notebook (
pip install notebookif needed)
Steps
Clone the repository
Clone the FFD repository from GitHub and move into the project directory:The repository contains the notebook (
Design_Project.ipynb) and the dataset (Creditcard_dataset.csv) in the same directory. The notebook loads the CSV by relative path, so both files must remain together.Install dependencies
Install all required packages with a single
pip command:tensorflow==2.11 is pinned to this exact version. The notebook uses tensorflow.keras APIs (including BatchNormalization, LeakyReLU, RandomNormal, and the functional Model API) that require TensorFlow 2.11 for compatibility. Installing a different version may cause import errors or unexpected behavior.Launch Jupyter
Open the notebook directly from the project root:Your browser will open the notebook. All cells must be run from the project root so that the relative path
Creditcard_dataset.csv resolves correctly.Run cells in order
Execute every cell from top to bottom. The notebook is divided into eight sequential steps:
| Step | What it does |
|---|---|
| 1 — Import dependencies | Installs and imports TensorFlow/Keras, scikit-learn, XGBoost, LightGBM, pandas, NumPy, and visualization libraries. Prints Modules are imported! on success. |
| 2 — Load dataset | Reads Creditcard_dataset.csv into a DataFrame (data = pd.read_csv("Creditcard_dataset.csv")), then displays shape (50492, 31) and class counts (0: 50000, 1: 492). |
| 3 — Data preprocessing | Drops NaN rows, removes the Time column, scales Amount with StandardScaler, splits features x and labels y, and renders a 2-D PCA scatter plot of the full dataset. |
| 4 — Build generator | Defines and calls build_generator() — a Keras sequential model that maps a noise vector to a 29-dimensional synthetic fraud sample using Dense, BatchNormalization, LeakyReLU, and Dropout layers. |
| 5 — Build discriminator | Defines and calls build_discriminator() — a Keras sequential binary classifier (input_dim=29) that learns to separate real from fake fraud records. |
| 6 — Assemble and train the GAN | Calls build_gan(generator, discriminator), freezes the discriminator weights (discriminator.trainable = False), compiles the combined model with adam optimizer and binary_crossentropy loss, then runs the full 1,000-epoch training loop. |
| 7 — Generate synthetic data | Calls generate_synthetic_data(generator, 1000) to produce 1,000 synthetic fraud samples, then plots real vs. synthetic distributions side-by-side using PCA for visual validation. |
| 8 — Train classifiers and evaluate | Combines real and synthetic fraud data, trains all six classifiers, and prints classification reports and confusion matrix heatmaps for each. |
What Happens Next
GAN Training
The GAN trains for 1,000 epochs with a batch size of 64 (32 real + 32 synthetic samples per discriminator update). During training,monitor_generator() is called periodically to visualize generator quality: it applies PCA to both real fraud samples and the generator’s current output, then plots both distributions on a shared 2-D scatter plot so you can watch the synthetic data converge toward the real distribution.
Synthetic Data Generation
After training,generate_synthetic_data(generator, 1000) draws 1,000 random noise vectors from a standard normal distribution, passes them through the trained generator, and returns 1,000 synthetic fraud feature vectors. These samples are used to visually compare the synthetic distribution against the 492 real fraud records via PCA scatter plots, confirming the generator has learned a realistic fraud distribution.
Classifier Training
Six classifiers are instantiated and fitted on the augmented (real + synthetic) training set in a single code cell:Expected Output
For each of the six classifiers the notebook prints a full classification report and renders a confusion matrix heatmap. You will see per-class metrics for both the genuine (0) and fraudulent (1) transaction classes:
| Metric | Description |
|---|---|
| Accuracy | Overall fraction of correctly classified transactions |
| Precision | Of all transactions predicted as fraud, how many actually were |
| Recall | Of all actual fraud transactions, how many were caught |
| F1-score | Harmonic mean of precision and recall — the primary metric for imbalanced problems |
seaborn) shows true positives, false positives, true negatives, and false negatives for each model, making it easy to compare how different classifiers handle the fraud vs. genuine trade-off.