Tabular Classification
Scikit-learn
Joblib
HistGradientBoostingClassifier (binary) -> P(fraud)
fraud-detection
banking
Instructions to use yssfmlha/transfer-fraud-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use yssfmlha/transfer-fraud-model with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("yssfmlha/transfer-fraud-model", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Bank transfer fraud model (feature input)
Gradient-boosted classifier. You compute the 15 features yourself and pass them in; the model returns P(fraud) and a risk level 0-3. Trained on a synthetic dataset - validate on real data.
Usage
from huggingface_hub import snapshot_download
import sys
folder = snapshot_download("YOUR_USERNAME/YOUR_REPO"); sys.path.insert(0, folder)
from predict import FraudModel
model = FraudModel.load(folder)
print(model.predict({'amount': 361.71, 'hour': 2.115, 'day_of_week': 2.0, 'history_count': 87.0, 'is_new_destination': 0.0, 'times_sent_to_destination': 3.0, 'days_since_last_to_destination': 0.0373, 'amount_vs_avg': 1.3774, 'amount_zscore': 0.3393, 'amount_vs_max': 0.2473, 'hour_familiarity': 0.046, 'hours_since_last_transfer': 0.6567, 'transfers_last_1h': 4.0, 'transfers_last_24h': 4.0, 'distinct_destinations_last_24h': 2.0}))
predict accepts one dict, a list of dicts, or a pandas DataFrame with these columns (extra columns are ignored,
order doesn't matter, missing ones raise an error).
Input features
| feature | definition |
|---|---|
amount |
Amount of the transfer being checked (same currency as in training). |
hour |
Hour of day as a decimal in the customer's LOCAL time (14:30 -> 14.5), range 0-24. |
day_of_week |
Monday=0 ... Sunday=6. |
history_count |
Number of the sender's earlier transfers in the last 180 days. |
is_new_destination |
1 if the sender never sent to this destination account in the last 180 days, else 0. |
times_sent_to_destination |
How many earlier transfers (last 180 days) went to this destination. |
days_since_last_to_destination |
Days since the sender's last transfer to this destination; -1 if never. |
amount_vs_avg |
amount / average amount of the sender's earlier transfers; 1.0 if no history. |
amount_zscore |
(amount - mean of earlier amounts) / std of earlier amounts; 0.0 if no history or std = 0. |
amount_vs_max |
amount / largest earlier transfer amount of the sender; 1.0 if no history. |
hour_familiarity |
Share (0-1) of the sender's earlier transfers made within +-2h of this hour (circular: 23:00 and 01:00 are 2h apart); 0.5 if no history. |
hours_since_last_transfer |
Hours since the sender's previous transfer (any destination); -1 if no history. |
transfers_last_1h |
Number of the sender's earlier transfers in the previous 1 hour. |
transfers_last_24h |
Number of the sender's earlier transfers in the previous 24 hours. |
distinct_destinations_last_24h |
Number of different destination accounts among those last-24h transfers. |
"History" = the sender's transfers strictly before the one being scored, within the last 180 days.
Risk levels (probability cut-offs: [0.0053, 0.0819, 0.5633])
| level | label | test transfers | fraud | fraud share |
|---|---|---|---|---|
| 0 | low | 41,273 | 26 | 0.1% |
| 1 | elevated | 2,355 | 103 | 4.4% |
| 2 | high | 473 | 168 | 35.5% |
| 3 | critical | 502 | 456 | 90.8% |
Test metrics
{ "roc_auc_test": 0.9924, "pr_auc_test": 0.8382, "fraud_rate_test": 0.0169, "alert_precision_level2plus": 0.64, "alert_recall_level2plus": 0.8287, "recall_level1plus": 0.9655 }
- Downloads last month
- -