Identifying those responsible for stealing the credit cards
Having identified the affected parties and seeing how much they lost, let's now find out who is responsible for this.
Getting ready
To execute this recipe, you will need NetworkX
, collections
, and NumPy
. No other prerequisites are required.
How to do it…
In this recipe, we will attempt to find the merchant that all the affected parties shopped at before the first fraudulent transaction occurred (the graph_fraudOrigin.py
file):
import networkx as nx import numpy as np import collections as c # import the graph graph_file = '../../Data/Chapter08/fraud.gz' fraud = nx.read_graphml(graph_file) # identify customers with stolen credit cards people_scammed = c.defaultdict(list) for (person, merchant, data) in fraud.edges(data=True): if data['disputed']: people_scammed[person].append(data['time']) print('\nTotal number of people scammed: {0}' \ .format(len(people_scammed))) # what was the time of the first disputed transaction...