
train a machine learning model to detect fraud on a credit card dataset and compare baseline and updated models with Streamlit dashboard, toggling thresholds and analyzing total cost of fraud.
Explore anomaly detection as identifying rare observations that deviate from the norm in fraud detection, with thresholds, box plots, and multi-dimensional data considerations.
Fraud detection identifies anomalous financial records within normal tabular transactions. Use feature engineering, customer- and transaction-level data, and network insights to detect fraud, with the credit card fraud dataset.
Explore the credit card fraud dataset with pandas, reading the CSV, inspecting the dataframe, and noting PCA-derived features v1–v28 for fraud detection.
Manage fraud labels and address severe class imbalance in pandas by analyzing label counts. Use upsampling, smote, downsampling, anomaly detection, or class weights to rebalance supervised models.
Explore class imbalance in fraud detection by using supervised binary classification and careful train-test splitting with stratification, ensuring fraud cases appear in both sets.
Train a logistic regression model for fraud detection with scikit-learn, using a train-test split; evaluate with a confusion matrix showing true positives, false positives, true negatives, and false negatives.
Balance the logistic regression by tuning class weights to address data imbalance and evaluate with a confusion matrix for fraud detection, highlighting increased true positives and controlled false positives.
Train an XGBoost model for fraud detection, building on a logistic regression baseline in a supervised learning context. Assess performance with a confusion matrix and tune hyperparameters for class imbalance.
Tune the xgboost classifier's hyperparameters to improve fraud detection. Use a positive weight of 100 and a maximum depth of 5, exploring trade-offs with Hyperopt and Optuna.
Explore how to interpret an XGBoost model for fraud detection, examining the classes attribute and feature importances in a multi-class setup to identify the most influential feature, notably feature 14.
Analyze a confusion matrix to attach operational costs to misclassifications in fraud detection, calculate total fraud cost per model, and compare xgboost with logistic regression.
Explain why accuracy is a poor metric for fraud detection due to severe class imbalance, showing that predicting all non-fraudulent transactions yields misleadingly high accuracy despite missing fraud.
Explore evaluating fraud detection models with precision, recall, F1 and F-beta, ROC AUC, PRC, and the classification report using scikit-learn, based on confusion matrices, thresholds in imbalanced data.
This lecture shows how to optimize fraud detection thresholds by evaluating area under the precision-recall curve using predicted fraud probabilities from a trained xgboost model.
Optimize fraud threshold using total cost of fraud with an xgboost model, leveraging PRC scores and confusion-matrix costs, identifying the 50% threshold and preparing data for a streamlit dashboard.
Learn to build interactive fraud-detection dashboards with Streamlit in Python, install via pip, and run a browser-based demo to explore thresholds, compare models, and compute total cost of fraud.
Compare fraud detection thresholds in a Streamlit dashboard, exploring how raising the threshold from 50% to 80% impacts total fraud cost and performance metrics like AUC and average precision.
Learn to balance an imbalanced fraud detection dataset by upsampling the minority class with SMOTE, retraining an xgboost model, and tuning sampling strategy to improve performance while managing false positives.
If you're interested in detecting fraud using machine learning, then this course is for you!
Fraud is a massive problem for many modern organizations, as bad actors are becoming increasingly sophisticated both in methodology and technical ability. Detecting fraud is therefore an important problem that is never going to be completely solved. By taking this course, you'll be levelling up with a hireable skillset that is likely going to be relevant and for many years to come.
This course was developed by myself, a Principal Data Scientist with a PhD in Machine Learning and real-world expertise in deploying production machine learning models for detecting fraud in the financial services industry.
In this course, students will be introduced to the problem of fraud in industry, and how it can be solved via the introduction of various machine learning approaches. I will walk you through an example fraud detection problem, where you will get hands-on exposure to building models using Python. This will include navigating the challenging problem of fraud, where special consideration needs to be given to the highly imbalanced nature of the data.
The lessons covered in this course include:
Lesson 1 - Introduction to fraud detection: anomaly detection, class imbalance
Lesson 2 - Training a supervised machine learning model to detect fraud: logistic regression, XGBoost, performance improvement through hyperparameter optimization
Lesson 3 - Performance metrics for fraud detection: confusion matrix, cost of misclassification, accuracy paradox, implementing metrics in scikit-learn
Lesson 4 - Optimal model selection: threshold optimization using performance metrics, threshold optimization using cost of fraud, introduction to Streamlit, building a threshold simulator for visual inspection
Lesson 5 - Strategies for improving model performance: sampling techniques
Each lesson builds on the practical knowledge achieved in the prior lessons, allowing for students to produce a completed end-to-end project as the final output of the course. This project could serve as an important part of a student's portfolio of projects, assisting with their job search and professional development endeavors.
The Python technology stack used within this course includes the following: pandas, numpy, matplotlib, scikit-learn, seaborn, XGBoost, Streamlit and imblearn.