Use ChatGPT to detect credit card fraud

Use ChatGPT to detect credit card fraud

Aug 27, 2023

I would like to an example of how you can use Code Interpreter to process data, execute logic and create interesting new data.

This is a map which shows card shows credit card transactions that are suspicious, where the card information possibly has been stolen and misused.

The map is based on a dataset of just over 294,589 credit card transactions from the United States that contained GPS coordinates for where each credit card transaction took place. The data is quite old as it is from 2015, but the principles are the same today (although maybe there is a little better security these days
)
I thought it could be interesting to see whether you could get Code Interpreter to do an analysis where you could identify suspicious transactions based on thousands of card transactions.

The logic I applied and prompted Code Interpreter with was that it should scan all 294589 credit card transactions. If there was a credit card transaction that was 150% above the average amount of the card's transactions and was executed over 1000 km from a 200 km radius of the card's other transactions, then it should flag those transactions as 'Suspect'.

After reviewing all credit card transactions, it identified 349 of these transactions as 'Suspect' ie. approx. 0.12%. The vast majority outside the US. Some of these transactions must be assumed to be vacations and business trips, but others appear to be fraudulent.

In order not to give Code Interpreter too much work at once, I copied these 'Suspect' transactions into a new sheet and prompted Code Interpret to find the location in the world of these transactions and update the sheet with this information rather than just showing the GPS coordinate.

I had to execute all the code in Python, but it was surprisingly fast (I think it took about 20 to go through all the transactions on the first run).

Then probably also around 15 minutes for the much smaller data set with suspicious transactions, where it had to use the slow Geopy library to find the place name for the location itself. (see screenshot).

I wouldn't say it was easy, but it wasn't extremely difficult either.

Enjoy this post?

Buy Kim Steffensen a coffee

More from Kim Steffensen