Skip to main content
ByPhilipp Singer
Fraud detection on the raw dataframe: fit, predict, done. The Credit Card Fraud Detection dataset is one of the most used tables on Kaggle. It holds 284,807 card transactions from two days in September 2013, of which only 492 (0.172%) are fraudulent. The features are 28 anonymized PCA components plus the transaction Time and Amount. The dataset authors recommend the area under the precision-recall curve (AUPRC) as the metric, because accuracy and even ROC AUC say little when one class is this rare. Most public notebooks on this dataset spend their effort on the imbalance: undersampling, SMOTE, class weights, threshold sweeps. TabPFN is a tabular foundation model that predicts in a single forward pass with no per-dataset training, and it is robust to imbalance out of the box. This notebook hands it the raw dataframe through the hosted API (tabpfn-client), so no GPU is needed, and compares the result with the reference models from the most popular Kaggle notebooks, trained on exactly the same columns with no feature engineering, so the comparison stays fair. Summary:
  • One fit, one predict, no imbalance tricks. TabPFN reaches an AUPRC of about 0.90 and a ROC AUC of about 0.99 on a held-out 20% split, straight from the 30 raw columns.
  • Ahead of the Kaggle reference models on the same columns. On the same split, the XGBoost configuration from the most popular modeling notebook reaches 0.84 AUPRC, a 100-tree random forest 0.87, and XGBoost with library defaults 0.78.
  • The ranking holds across folds. In a 5-fold stratified cross-validation TabPFN wins every fold, with a mean AUPRC of 0.89 against 0.85 for the random forest and 0.81 for the reference XGBoost, so the conclusion does not rest on a single set of 98 test frauds.

Setup

Installing the TabPFN client, the Kaggle download helper, and the reference models, pinned to the versions this notebook was run with.

Load the data

Downloading the dataset from Kaggle and taking a first look. kagglehub loads public datasets straight into a dataframe without a Kaggle account. The table has no missing values, and all 30 feature columns are numeric. We drop nothing and engineer nothing: Time (seconds since the first transaction), Amount, and V1 to V28 go into every model exactly as they arrive.

Train/test split

A stratified 80/20 split, the setup used by the Kaggle notebooks we compare against. Stratification keeps the fraud rate identical in both halves, which leaves 98 frauds in the test set. The public notebooks split at random, and we follow them so the reference numbers are comparable. A production fraud model would be validated out of time (train on the first day, test on the second) to catch drift; the cross-validation at the end of this notebook is the more robust check within this protocol.

Metrics

AUPRC as the headline, ROC AUC for reference, and one operational number.
  • AUPRC (average precision) summarizes precision against recall across all thresholds. A model with no information scores the fraud rate, here 0.0017, so every gain is visible. This is the metric the dataset authors recommend.
  • ROC AUC measures how well frauds rank above legitimate transactions. It is the most reported number on Kaggle, but on data this imbalanced it saturates near 1 and hides real differences.
  • Alerts to catch 90% of frauds: sort the 56,962 test transactions by score and count how many an analyst team has to review before 90% of the 98 frauds are found. This is the workload behind a recall target, and it is where models that look alike on the first metrics come apart.
Every model records its scores into one results list for the final table.

Authentication

Setting the API token so the client can reach the hosted model. The client reads the API key through set_access_token. Here we pull it from Colab secrets; outside Colab, set the TABPFN_TOKEN environment variable. Get a token at platform.priorlabs.ai. We pin the model to TabPFN 3.5 with create_default_for_version, so the numbers in this notebook stay reproducible after future releases. Use TabPFNClassifier() instead to always get the current default model.

TabPFN

Default settings, the raw dataframe, no resampling. fit uploads the training table and predict_proba runs the in-context learning on Prior Labs’ servers. There are no hyperparameters to set and no class weights to pick.

Reference models from Kaggle

The same 30 columns, the model configurations the community converged on. We take the reference models from public notebooks on this dataset, keeping their configurations and dropping any resampling or feature engineering:
  • XGBoost, Kaggle configuration. Gabriel Preda’s Credit Card Fraud Detection Predictive Models is the most upvoted modeling notebook on the dataset that trains on the raw columns. Its XGBoost uses shallow trees (max_depth=2), a learning rate of 0.039, row and column subsampling, and up to 1,000 boosting rounds with early stopping on a validation slice. We reproduce that recipe, carving the validation slice out of our training set so the test set stays untouched.
  • XGBoost, library defaults. Several notebooks, for example ANNs vs XGBoost, simply call XGBClassifier().
  • Random forest. The 100-tree RandomForestClassifier that opens Preda’s notebook, and a common first model in many others.

Results

One table, four models, the same 30 columns. TabPFN leads on both ranking metrics. Every ROC AUC sits above 0.92 and the top three are within three points of each other, which is exactly why the dataset authors ask for AUPRC: there the spread between the same models is twelve points. The workload column makes the difference concrete: to catch 90% of the frauds, analysts review about 135 alerts with TabPFN, roughly 190 with the random forest, and more than 600 with the reference XGBoost, with no threshold tuning for any model.

Precision-recall curves

Where the AUPRC gap comes from. The curves show precision (how many flagged transactions are fraud) against recall (how many frauds are caught). TabPFN holds higher precision as recall increases, which is the regime a fraud team operates in: catch most of the fraud without drowning analysts in false alarms. The dashed line is the fraud rate, the precision of flagging at random.
Precision-recall curves

Is one split enough?

Repeating the comparison with 5-fold stratified cross-validation. A test set with 98 frauds is small, and the AUPRC of any model moves by a few points from split to split. To check that the ranking is not an artifact of one split, we run all models on five stratified folds. Each model is fit on 80% of the data and scored on the remaining 20%, so every transaction is a test row exactly once. Same columns, same configurations, no tuning on the folds.

Takeaways

  • No imbalance handling needed. TabPFN sees 394 frauds among 227,845 rows and ranks them well without undersampling, SMOTE, or class weights. The default probabilities can be thresholded directly for a review queue, and that queue is the shortest of the four models for the same recall.
  • No feature engineering, no tuning. The reference models were configured by experienced Kaggle authors; TabPFN was not configured at all and still comes out ahead on AUPRC across the folds.
  • Fair comparison, real caveats. All models saw the same 30 columns and a random stratified split. A production evaluation would split by time and would likely add merchant, card, and velocity features that this anonymized dataset cannot provide. For grouped or temporal fraud data, the Thinking mode of the client is a natural next step.