@@ -4,8 +4,7 @@ Add suspicious-login detection, auth-risk scoring, and step-up decisions to your
44
55![ MIT License] ( https://img.shields.io/badge/license-MIT-green.svg )
66![ Python 3.9+] ( https://img.shields.io/badge/python-3.9%2B-blue.svg )
7- ![ Tests Passing] ( https://img.shields.io/badge/tests-32%20passing-brightgreen.svg )
8- ![ Pip Installable] ( https://img.shields.io/badge/pip-installable-orange.svg )
7+ ![ Tests Passing] ( https://img.shields.io/badge/tests-35%20passing-brightgreen.svg )
98
109## Why This Exists
1110Every fintech and crypto app builds auth-risk scoring internally because generic fraud tooling rarely models authentication flow context well. Teams need to distinguish legitimate users from attackers before full identity verification and before adding friction. This project packages those patterns into an open-source toolkit with synthetic-data-first workflows so you can run everything locally.
@@ -37,26 +36,39 @@ Auth Events
3736Action: allow | step-up | review | block | revoke
3837```
3938
40- ## Quickstart
39+ ## Install
4140``` bash
42- pip install identity-risk-engine
41+ git clone https://github.com/KOKOSde/identity-risk-engine.git
42+ cd identity-risk-engine
43+ python3 -m pip install -e .
4344```
4445
46+ ## Quickstart
4547``` python
4648from identity_risk_engine.simulator_ire import generate_synthetic_auth_events
4749from identity_risk_engine.policy_engine import PolicyEngine
48- from identity_risk_engine.risk_engine_ire import score_dataframe
50+ from identity_risk_engine.risk_engine_ire import score_event
4951
5052events = generate_synthetic_auth_events(num_users = 50 , num_sessions = 1000 , attack_ratio = 0.2 , seed = 42 )
51- scored = score_dataframe(events, policy_engine = PolicyEngine())
52- print (scored[[" event_id" , " risk_score" , " action" ]].head())
53+ event = events.iloc[50 ].to_dict()
54+ history = events.iloc[:50 ]
55+ result = score_event(event = event, history_df = history, policy_engine = PolicyEngine())
56+
57+ print (result[" risk_score" ], result[" decision" ][" action" ])
58+ print (result[" explanation" ][" human_summary" ])
5359```
5460
61+ ` PolicyEngine ` exposes ` decide() ` (not ` evaluate() ` ), and per-event explanations are returned by ` risk_engine_ire.score_event() ` under ` result["explanation"] ` .
62+
5563## CLI Quickstart
5664``` bash
57- identity-risk-engine simulate --users 500 --sessions 20000 --attack-ratio 0.2 --out synthetic.csv
58- identity-risk-engine score --events synthetic.csv --policy configs/default_policy.yaml --out scored.csv
59- identity-risk-engine report --events scored.csv --out report.html
65+ python3 -m identity_risk_engine.cli_ire simulate --users 500 --sessions 20000 --attack-ratio 0.2 --out synthetic.csv
66+ python3 -m identity_risk_engine.cli_ire score --events synthetic.csv --policy configs/default_policy.yaml --out scored.csv
67+ python3 -m identity_risk_engine.cli_ire report --events scored.csv --out report.html
68+ # fast demo mode for large files:
69+ python3 -m identity_risk_engine.cli_ire score --events synthetic.csv --policy configs/default_policy.yaml --fast --out scored_fast.csv
70+ # force full scoring mode even on large files:
71+ python3 -m identity_risk_engine.cli_ire score --events synthetic.csv --policy configs/default_policy.yaml --full --out scored_full.csv
6072```
6173
6274## FastAPI Quickstart
@@ -114,15 +126,16 @@ Supported actions: `allow`, `allow_with_monitoring`, `step_up_with_passkey`, `st
114126
115127# # Benchmark Results
116128Run details : ` num_users=100` , `num_sessions=2400`, `attack_ratio=0.22`, `seed=21`, time split from `demo_outputs/benchmark_output_ire.txt`.
129+ Reproducible with `seed=42` in model training and deterministic model settings.
117130
118131| Cohort | AUC | Precision@0.95Recall | Recall@0.95Precision |
119132|---|---:|---:|---:|
120133| Global | 1.000 | 1.000 | 1.000 |
121- | account_takeover | 0.914 | 0.246 | 0.000 |
122- | bot_behavior | 0.904 | 0.138 | 0.000 |
123- | credential_stuffing | 0.915 | 0.262 | 0.000 |
124- | impossible_travel | 0.907 | 0.177 | 0.000 |
125- | new_account_fraud | 0.907 | 0.177 | 0.000 |
134+ | account_takeover | 0.916 | 0.246 | 0.000 |
135+ | bot_behavior | 0.906 | 0.138 | 0.000 |
136+ | credential_stuffing | 0.908 | 0.262 | 0.000 |
137+ | impossible_travel | 0.910 | 0.177 | 0.000 |
138+ | new_account_fraud | 0.910 | 0.177 | 0.000 |
126139
127140# # Demo Output
128141CLI report summary snippet (from `/tmp/ire_report.html` generated by CLI) :
@@ -161,9 +174,6 @@ FastAPI `/simulate` response snippet (from `demo_outputs/fastapi_simulate_ire.tx
161174- Fraud analysts
162175- Security researchers
163176
164- # # Case Study
165- Coinbase case study notebook placeholder : ` notebooks/coinbase_case_study.ipynb` (to be added in a follow-up).
166-
167177# # Related Projects
168178- [onchain-sybil-detector](../onchain-sybil-detector)
169179- [LocalMod](../LocalMod)
0 commit comments