The raw credit card transaction dataset requires several cleaning and transformation steps before it can be used to train fraud detection models. This page walks through each preprocessing stage — from loading the CSV to producing a PCA scatter plot that reveals how genuine and fraudulent transactions cluster in two-dimensional space.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.
Loading the Dataset
The dataset is a CSV file containing 50,492 transaction rows and 31 columns (including theClass label). Load it with pandas and take an initial look at its structure:
Class column is the target label: 0 for genuine transactions and 1 for fraudulent ones. The remaining 30 columns are either raw transaction features (Time, Amount) or PCA-transformed anonymised features (V1–V28).
Cleaning Steps
Remove rows with NaN values
Drop any row that contains at least one missing value to ensure every sample is complete before training.
Drop the Time column
The
Time column records elapsed seconds since the first transaction and carries no predictive signal once the dataset is shuffled for training. It is removed entirely.Scale the Amount column
Transaction amounts vary across several orders of magnitude. Applying
StandardScaler brings Amount onto the same scale as the anonymised V1–V28 features, preventing large raw values from dominating distance-based and gradient-based learners.PCA Visualization
After cleaning, a two-component PCA projection gives an intuitive visual check of how separable the two classes are before any model is trained.Why drop
Time and scale Amount?
Time is an absolute counter that leaks chronological ordering — a model trained on early transactions and tested on later ones could learn spurious temporal patterns rather than genuine fraud signals. Dropping it makes the pipeline robust to any re-ordering of the data.Amount is the only feature left in its original monetary scale after Time is removed. Without scaling, its raw magnitude (which can reach thousands) would dominate algorithms that rely on Euclidean distances (KNN) or gradient magnitudes (neural networks in the GAN), leading to slower convergence and biased decision boundaries.