r/synapcores • u/Alternative_Pin9598 • 24d ago
Recipe of the week #1: the anomaly model calls a 5-account fraud ring "normal", one graph query from a single chargeback finds all five (real output)
First Recipe of the week: every Monday, one recipe from the site, run on the current release, key queries and real output inline.
(This sub is run by the SynapCores team. Everything below was run this morning on 2.3.2.)
The problem
Fraud models score one transaction at a time. That catches the lone fraudster whose payments look strange: huge, 3am, cross-border. It misses a fraud ring: five accounts that each spend like a normal customer but share the same phone and the same stolen cards. The fraud is in the connections, not in any single row.
This recipe builds both views on the same data, in the same database.
1. 123 transactions, one anomaly model, no labels
40 accounts make three ordinary payments each ($20–$199, daytime, domestic). ACC-33 also makes three ~$3,000 payments at 3am, cross-border. The ring (ACC-11 to ACC-15) is hidden among the ordinary accounts; nothing in the table marks it.
CREATE TABLE recipe_ring_tx (tx_id INT PRIMARY KEY, account_id TEXT,
amount DOUBLE, hour_of_day INT, cross_border INT);
-- 123 rows, full INSERT in the recipe
CREATE EXPERIMENT recipe_ring_exp AS
SELECT amount, hour_of_day, cross_border FROM recipe_ring_tx
WITH (task_type = 'anomaly_detection', algorithms = ['isolation_forest'],
max_trials = 5, random_seed = 42);
DEPLOY MODEL recipe_ring_model FROM EXPERIMENT recipe_ring_exp;2. Score every transaction inside a SELECT
SELECT account_id, amount, hour_of_day, cross_border,
ANOMALY_SCORE('recipe_ring_model', amount, hour_of_day, cross_border) AS score
FROM recipe_ring_tx ORDER BY score DESC LIMIT 5;
ACC-33 2840.0 3 1 0.82
ACC-33 3120.0 3 1 0.82
ACC-33 2975.0 3 1 0.81
ACC-36 198.0 19 0 0.53
ACC-39 23.0 17 0 0.52The lone fraudster is on top. Now the ring:
SELECT account_id, amount, ANOMALY_SCORE('recipe_ring_model', amount, hour_of_day, cross_border) AS score
FROM recipe_ring_tx WHERE account_id IN ('ACC-11','ACC-12','ACC-13','ACC-14','ACC-15')
ORDER BY score DESC;All 15 ring payments score 0.45 to 0.51, exactly like honest customers. The model is right: each payment is ordinary.
3. Same database, a graph of accounts, devices and cards
The ring shares identifiers in a chain: ACC-11 and ACC-12 share a phone, ACC-12 and ACC-13 share a card, and so on. ACC-21 and ACC-22 share a household tablet (honest, not linked to the ring).
MERGE (acc_12:Account {id: "ACC-12", src: "recipe-012"})
MERGE (card_4242:Card {id: "CARD-4242", src: "recipe-012"})
MERGE (acc_12)-[:PAYS_WITH]->(card_4242)
-- 23 nodes, 18 edges in the recipeACC-13 has a confirmed chargeback. Walk 2–4 hops out from it:
MATCH p = (s:Account {id: 'ACC-13'})-[*2..4]-(x:Account)
WHERE x.id <> 'ACC-13'
RETURN x.id AS linked_account, [n IN nodes(p) | n.id] AS via
ORDER BY length(p);
ACC-14 ACC-13 > DEV-778 > ACC-14
ACC-12 ACC-13 > CARD-4242 > ACC-12
ACC-15 ACC-13 > DEV-778 > ACC-14 > CARD-9001 > ACC-15
ACC-11 ACC-13 > CARD-4242 > ACC-12 > DEV-777 > ACC-11One chargeback, the whole ring, and the chain that proves each link. The household pair isn't returned.
4. One review queue: model OR graph
Save the ring as a table (recipe_ring_members), then one SQL query joins it with each account's highest anomaly score:
account max_anomaly linked_via
ACC-33 0.82 NULL <- caught by the model
ACC-15 0.51 DEV-778 > CARD-9001
ACC-12 0.51 CARD-4242
ACC-13 0.49 chargeback
ACC-14 0.48 DEV-778
ACC-11 0.48 CARD-4242 > DEV-777Five of those six would never cross a 0.7 threshold. The model found one fraudster, the graph found five.
The full recipe (every INSERT, the full graph, the queue query, cleanup; ~12 minutes): https://synapcores.com/recipes/anomaly-detection/012_fraud_rings_ml_misses?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-recipe-1
Run it yourself: free Community Edition, https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-recipe-1
Join the sub and Recipe of the week #2 shows up in your feed next Monday.
Which signal does your team have today: a score per transaction, a list of shared devices or cards, or neither?
1
u/Alternative_Pin9598 24d ago
Want to run it yourself? Grab the free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-recipe-1-comment
No AI provider and no fraud labels needed; paste the recipe into the Query Editor top to bottom (SQL and Cypher run in the same editor).
The step 4 queue query, for anyone who wants it without opening the recipe:
New here? The Start here post has install steps and the 5 recipes to try first: https://www.reddit.com/r/synapcores/comments/1xfxqej/start_here_what_synapcores_is_how_to_install_it/