Anomaly Detection

_

Mi'kail Eli'yah
6 min readJun 19, 2024

Similar to Part 7: Death Note — `How to Catch Kira`, let’s illustrate an example of anomaly detection, such as fraud or identity theft, by checking frequency of transaction of user, in terms of velocity and acceleration in terms of its amount as well in terms of currency types with regards to geolocation and if the locations of the activities are far apart.

The same can be references from Tooling Guide: Introduction To Constructing Your Own Project `Ayahuasca` Tooling on profiling human analytics.
Part 1
Part 2

For visualization, plots are made by drawing the time-series and mapping out the transactions by geolocation.

Generate synthetic transaction data

import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import random

def generate_synthetic_transaction_data():
# Seed for reproducibility
seed_initial = 42
np.random.seed(seed_initial)
random.seed(seed_initial)

# Generate synthetic data
num_users = 5
num_transactions = 100
start_date = datetime(2024, 1, 1)

data = {
'user_id': np.random.choice(range(1, num_users+1), num_transactions),
'timestamp': [start_date + timedelta(days=random.randint(0, 30), seconds=random.randint(0, 86400)) for _ in…

--

--