Repository navigation
v1.2.0
GraphFaker generates graph data that behaves the way real people and real money do, with the ground truth included. 1.2 adds a third labelled domain, and turns the project outward: a real company register reads in, and a generated dataset writes out as an entity resolution problem with its answer key.
pip install graphfaker==1.2.0
graphfaker generate supply_chain --scale 0.01 --hardness medium --seed 42 --out ./chainThe supply chain pack
A multi-tier supplier network and the orders, shipments, invoices and deliveries on it: suppliers in three tiers, plants, warehouses, customers, products and carriers, with contracts, lanes and an event stream of scheduled replenishment, seasonal demand, shipments against promised lead times, invoices behind the goods, inter-company movements and outbound deliveries.
Four labelled plays, each paired with a legitimate structure that leaves the same trace: phantom_supplier with disruption_cascade, invoice_kiting with consignment_loop, split_orders with blanket_calloffs, counterfeit_injection with quality_incident. A port closure and a shell company produce the same ledger. A framework agreement and a split-order scheme produce the same histogram. A dataset whose only labelled structures are fraudulent rewards any detector that fires on the shape, and that is the detector that blocks honest suppliers.
hardness_report scores sixteen features in six families against the suppliers that actually trade. Writing the pack, that measurement found four label leaks, each of which would have made a play findable by one column: legitimate invoices were never round numbers, every legitimate invoice had a shipment behind it, inter-company movements only ran one way, and plays recruited suppliers with no contract. All four are fixed in the process rather than hidden from the features.
A threshold rule, the first thing anyone writes, finds every split-order scheme, misses the other three plays completely, and flags 42% of the suppliers running ordinary blanket agreements.
A real register in
graphfaker register PATH reads a register in Senzing's entity resolution format from a file, a directory or a zip, reports what is in it before you spend an hour on it, and with --out loads it into tables, a DuckDB or a LadybugDB. --state and --city cut a national export down to something that fits in memory.
benchmarks/realism/corporate.py measures a register into aggregate statistics, counts only, and scores a GraphFaker run on the same metrics. Two references ship with it, from registers with no records in common, and they agree: a Las Vegas file of 2,026,444 records and the 1,033,773 companies registered in Nevada inside a 330-million-record national export. A pass over the 158 GB export takes 26 minutes on twelve processes.
GraphFaker ships no register. The references are derived statistics, which is the only form of someone else's data that should travel.
What the register changed in the generator
- Addresses are shared. One address in the register holds 99,522 companies, and the top 1% of addresses hold over half of every record. That is the registered agent, and it is why address is not a blocking key. Giving every generated company its own address makes deduplicating on address work perfectly, which is the opposite of the lesson.
- Names are a distribution. LLC 53.9%, INC 20.5%, no legal form at all 11.9%,
L.L.C2.6%, and a comma before the suffix on half of them. Faker offeredPLCandand Sons. - Most companies have nobody. 4.5% of a register's companies have a single officer or contact attached. The ones that do have a median of one and a 99th percentile of 151, because the busy ones are filing agents. Board density has a floor of zero.
An entity resolution dataset out
graphfaker generate supply_chain --scale 0.01 --seed 42 --out ./chain --sink senzingsenzing/records.jsonl is the dataset, where the same company appears several times under several spellings and at addresses it shares with others, and a person is a record per company the way a register holds them. senzing/entities.parquet is the answer key. Nothing in the records names the entity.
Scored with graphfaker.resolve on 4,409 records for 2,207 companies: the name alone, blocked on its stem, gives 0.93 F1. Adding the address costs recall, because a company's records sit at different addresses. Matching on the address alone gives 0.03 precision. A dataset of unique names and unique addresses would have called all three a success.
docs/notebooks/register_resolution.ipynb runs the same resolver on a real register, where there is no answer key and therefore no score, and on a generated one where there is.
A correction
The 1.1 notes said different companies share a name 86.7% of the time, and that our generated names were two orders of magnitude too unique. The counting was wrong: a location record carries its parent's name, so a company with five sites writes its name five times, and that is what the 86.7% measured. Counting companies, it is 1%. The generated names were wrong in the other direction, too colliding at scale rather than too unique, because a thousand surnames do not go round. Both are fixed, and the measurement now reports the two separately.
Also
graphfaker gen --export no longer fails on a Windows console. A dataset with no edges no longer breaks the DuckDB property graph. The benchmark's name normaliser never stripped L.L.C, which was the one spelling the whole exercise is about.
Datasets change for a given seed in the supply_chain pack, which gained addresses, names and people. The fraud, social and coordination packs are byte-identical to 1.1.0.
Full changelog: HISTORY.rst. Docs: https://graphfaker.readthedocs.io