Data is available in https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud
This Python script demonstrates credit card fraud detection using Logistic Regression. It loads a dataset, preprocesses it, trains a Logistic Regression model, and evaluates its performance.
- Python 3.x
- pandas
- scikit-learn
- matplotlib
- Ensure you have the required libraries installed (
pandas
,scikit-learn
,matplotlib
). - Save your dataset as
creditcard.csv
in the same directory as the script. - Run the script in a Python environment.
-
Loading the Dataset: The script loads the credit card transaction dataset from
creditcard.csv
. -
Preprocessing: It separates features (X) and the target variable (y) and then splits the dataset into training and testing sets. It also standardizes the features using
StandardScaler
. -
Model Training: It creates a Logistic Regression model and fits it on the training data.
-
Evaluation: The model's performance is evaluated using the ROC AUC score. It also plots a precision-recall curve to visualize the precision-recall trade-off.