Skip to main content

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.

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.

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 notebook if needed)

Steps

1

Clone the repository

Clone the FFD repository from GitHub and move into the project directory:
git clone https://github.com/Antisource/FFD.git && cd FFD
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.
2

Install dependencies

Install all required packages with a single pip command:
pip install tensorflow==2.11 visualkeras numpy pandas scikit-learn seaborn matplotlib plotly xgboost lightgbm
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.
3

Launch Jupyter

Open the notebook directly from the project root:
jupyter notebook Design_Project.ipynb
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.
4

Run cells in order

Execute every cell from top to bottom. The notebook is divided into eight sequential steps:
StepWhat it does
1 — Import dependenciesInstalls and imports TensorFlow/Keras, scikit-learn, XGBoost, LightGBM, pandas, NumPy, and visualization libraries. Prints Modules are imported! on success.
2 — Load datasetReads 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 preprocessingDrops 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 generatorDefines 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 discriminatorDefines 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 GANCalls 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 dataCalls 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 evaluateCombines 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.
synthetic_data = generate_synthetic_data(generator, 1000)

Classifier Training

Six classifiers are instantiated and fitted on the augmented (real + synthetic) training set in a single code cell:
# Model 1: Random Forest
rf_model = RandomForestClassifier(n_estimators=100, random_state=42)
rf_model.fit(x_train, y_train)

# Model 2: Support Vector Machine
svm_model = SVC(kernel='rbf', gamma='scale', random_state=42)
svm_model.fit(x_train, y_train)

# Model 3: K-Nearest Neighbors
knn_model = KNeighborsClassifier(n_neighbors=5)
knn_model.fit(x_train, y_train)

# Model 4: Naive Bayes
nb_model = GaussianNB()
nb_model.fit(x_train, y_train)

# Model 5: XGBoost
xgb_model = xgb.XGBClassifier(random_state=42)
xgb_model.fit(x_train, y_train)

# Model 6: LightGBM
lgb_model = lgb.LGBMClassifier(random_state=42)
lgb_model.fit(x_train, y_train)

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:
MetricDescription
AccuracyOverall fraction of correctly classified transactions
PrecisionOf all transactions predicted as fraud, how many actually were
RecallOf all actual fraud transactions, how many were caught
F1-scoreHarmonic mean of precision and recall — the primary metric for imbalanced problems
The confusion matrix heatmap (rendered via 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.

Build docs developers (and LLMs) love