Skip to content

Identify fraudulent credit card transactions so that customers are not charged for items that they did not purchase. (Python, Logistic Regression Classifier, Unbalanced dataset).

Notifications You must be signed in to change notification settings

kpratikin/Credit-Card-Fraud

Repository files navigation

Credit Card Fraud Detection

Objective:

  • To detect fraudulent credit card transactions and
  • To understand how to work with imbalanced dataset.

Datset:
The dataset is downloaded from: https://www.kaggle.com/mlg-ulb/creditcardfraud
The datasets contains transactions made by credit cards in September 2013 by european cardholders. This dataset presents transactions that occurred in two days, where we have 492 frauds out of 284,807 transactions. The dataset is highly unbalanced, the positive class (frauds) account for 0.172% of all transactions.


Figure: Class (1- Fradulent transaction, 0- Non-fradulent transactions)

It contains only numerical input variables which are the result of a PCA transformation. Unfortunately, due to confidentiality issues, we do not have original features and more background information about the data. Features V1, V2, ... V28 are the principal components obtained with PCA, the only features which have not been transformed with PCA are 'Time' and 'Amount'. Feature 'Time' contains the seconds elapsed between each transaction and the first transaction in the dataset. The feature 'Amount' is the transaction Amount, this feature can be used for example-dependant cost-senstive learning. Feature 'Class' is the response variable and it takes value 1 in case of fraud and 0 otherwise.

Analysis:
For detailed analysis refer the Code: https://github.com/kpratikin/Credit-Card-Fraud/blob/master/Credit%20Card%20Fraud%20Final.ipynb

Following are the techniques I have tried out.

  1. Normalization of variables
  2. Cross-Validation
  3. Oversample minority class (i.e. fradulent transactions)
  4. Ensemble modelling (Random Forrest)
  5. Bagging
  6. Boosting (XGBoost, ADABoost)
  7. Changing the Threshold

    Conclusion:

    Out of all the methods we tried, we found that oversampling(SMOTE) method is best suited for our analysis. Significant high F1, Precision and recall scores are observed at a cost of small decline in the accuracy score.
    Thus, with use of oversampling(SMOTE) model, banks can better detect fradulent transactions.
    Summary of all the models are as follows:

    Model Accuracy AUC Precision Recall F1-Score
    Original Model 0.99 0.96 0.6 0.87 0.71
    Cross Validation 0.99 0.59 0.85 0.69
    Oversampling (SMOTE) 0.946 0.989 0.92 0.97 0.95
    Ensemble (Random Forrest) 0.99 0.928 0.93 0.75 0.83
    Bagging (Decision Trees) 0.99 0.97 0.61 0.88 0.72
    Boosting (XGBOOST) 0.99 0.98 0.79 0.92 0.85
    Boosting (ADABOOST) 0.99 0.969 0.83 0.65 0.73
    Threshold change to 10% 0.99 0.968 0.79 0.83 0.81

About

Identify fraudulent credit card transactions so that customers are not charged for items that they did not purchase. (Python, Logistic Regression Classifier, Unbalanced dataset).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published