Project 09 · Machine learning

Machine Learning Model · Fraud with Logistic Regression

✅ published

Analysis of credit card transactions to estimate the probability of fraud using logistic regression. The project uses information from previously classified transactions to train a model that identifies risk-related signals and allows its predictions to be analyzed.

Python
SPSS
Machine Learning
Logistic regression
Classification
Fraud

CONTEXT AND OBJECTIVE

The project uses credit card transaction records to study which characteristics occur more frequently in transactions associated with fraud. Each transaction contains information describing the operation and a classification indicating whether it was recorded as legitimate or fraudulent. This information allows a model to be trained on known examples and then applied to other transactions.

The objective is to estimate the probability of fraud for each transaction and identify which variables contribute to that estimate. Logistic regression addresses both tasks: it classifies transactions and allows the relationship between their characteristics and the predicted outcome to be interpreted.

MODEL AND EVALUATION

DATA PREPARATION

First, the variables in the transaction dataset are reviewed and the information the model will use is organized. Preparation includes data cleaning, variable preparation and class balancing, an important consideration when fraud cases are much less frequent than legitimate purchases.

This preparation makes the data ready for model training and evaluation. The selected variables describe each transaction, while the known fraud classification provides the reference from which the model learns to distinguish the two types of cases.

CLASSIFICATION WITH LOGISTIC REGRESSION

Logistic regression combines the characteristics of each transaction and estimates a probability of fraud between 0 and 1. Each variable contributes to the calculation through a coefficient fitted during training. The logistic function converts this combination into a probability for each transaction.

ESTIMATED PROBABILITY OF FRAUD
p(x)=\frac{1}{1+e^{-(\beta_0+\sum_{j=1}^{k}\beta_jx_j)}}

p(x) is the estimated probability of fraud. The x variables represent transaction characteristics; the beta coefficients reflect the contribution learned for each variable.

The coefficients allow analysis of how each characteristic relates to the estimated probability while accounting for the other variables. This helps identify signals associated with higher or lower risk within the transactions analyzed.

EVALUATION OF PREDICTIONS

Evaluation compares predictions with the known transaction classifications. To decide which transactions are flagged as possible fraud, the estimated probability is compared with a decision threshold. This value affects how many fraud cases are detected and how many legitimate purchases generate alerts for review.

THRESHOLD FOR CLASSIFYING TRANSACTIONS
\hat{y}=\begin{cases}1&\text{if }p(x)\geq t\\0&\text{if }p(x)<t\end{cases}

In this general rule, 1 identifies a possible fraud alert and 0 a transaction classified as legitimate. t is the decision threshold, whose specific value can be chosen according to the evaluation criterion.

The project implements the modeling process in SPSS Modeler and includes another implementation in Python. Evaluation metrics and charts allow the model’s performance and fraud-related signals to be analyzed using both tools.

DELIVERY AND LEARNING

The work presents a supervised logistic regression model applied to credit card transactions, together with variable preparation, predictions and evaluation results. Combining SPSS Modeler and Python makes it possible to follow the procedure and review the variables’ contributions to classification.

When new transactions with the same variables are added, the model can generate estimates that can later be compared with confirmed cases. This comparison checks whether its detection capability is maintained and helps determine when the training should be updated.