Measuring a Premium Plan Launch and Flagging Risky Accounts
Statistics & ExperimentsModel answerLast updated
Define primary, diagnostic and guardrail metrics for a paid-plan launch using only three tables, then build explainable rule-based SQL that scores accounts for financial-crime risk.
You are a data scientist at a fintech company. You may use only the three tables below (all timestamps are UTC). If something you want to measure is not directly available, propose and justify a proxy built from these columns.
Schema
users
user_idBIGINT, primary keycreate_dateTIMESTAMPcountryVARCHAR (may be absent)
transactions
transaction_idBIGINT, primary keyuser_idBIGINT, referencesuserstransaction_timeTIMESTAMPproductVARCHAR (for example'crypto', and possibly'ultra'if the plan is modelled as a product)amount_gbpNUMERIC(18,2)statusVARCHAR ('completed'or'declined')ip_countryVARCHAR (may be absent)
activity
user_idBIGINT, referencesusersevent_timeTIMESTAMPproductVARCHAR (may include'ultra')event_typeVARCHAR ('view'or'click')
Part A: Premium plan launch
The company launches a new paid plan called Ultra. You are asked to evaluate it over the first month.
- Define success: pick one primary metric, several diagnostic metrics, and several guardrail metrics.
- Describe the main threats to the validity of your conclusions (seasonality, concurrent marketing, selection bias, and so on) and how you would mitigate each.
- Write SQL or pseudo-SQL that computes your metrics from the tables above.
Part B: Financial-crime screening
The Financial Crime team wants help flagging suspicious behaviour.
- Propose a rule-based approach that turns "suspicious" into concrete, testable rules using the available data.
- Write SQL or pseudo-SQL that outputs the suspicious entities. State which output you chose:
- suspicious
user_ids with arisk_scoreand the rules triggered, or - suspicious
transaction_ids with flags and reasons.
- suspicious
- Discuss false-positive versus false-negative trade-offs, and explain how you would evaluate the rules and iterate on them.
State your data assumptions up front. Answer in a structured way, as you would in a live discussion.
Hints
Hint 1
Start by deciding what an Ultra purchase looks like in the data. A completed transaction on the Ultra product is the strongest signal; a click in `activity` is a weaker intent-only fallback. Say which you use and why.
Hint 2
Fix the denominator of your primary metric before launch (for example, users active in the 30 days prior) so the launch itself cannot change who is counted. Then separate diagnostics (funnel, decline rate, time to convert) from guardrails (things that must not get worse).
Hint 3
For Part B, choose user-level output, give each rule a weight and a typology (velocity, card testing, new account with high value, geo mismatch), sum the weights into a score, and keep the triggered rule names as reasons. Plan how you would tune thresholds using analyst-reviewed cases.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Assumptions
- A completed
transactionsrow withproduct = 'ultra'is a subscription payment; the user's first one is their subscription start. - If Ultra is not in
transactions, fall back to aclickon Ultra inactivity. This measures intent, not purchase, so I would flag it clearly as a weak proxy. - There is no cancellation data and a one-month window shows no renewals, so retention is a follow-up, not part of the primary metric.
Part A: Launch evaluation
Metrics
Primary: 30-day paid adoption rate.
- Numerator: eligible users with at least one completed Ultra payment in the 30 days after launch.
- Denominator: users with any activity in the 30 days before launch. It is fixed before launch, so the launch cannot inflate it, and it links directly to revenue (adoption x price).
Diagnostic (why did the primary move?):
- Funnel: view, click, completed payment, with conversion at each step.
- Ultra decline rate (declined attempts / all attempts), which separates payment friction from weak demand.
- Median time from first Ultra view to payment.
- Adoption by tenure (new vs. older than 90 days) and by country.
- Subscriber behaviour before vs. after subscribing (transactions per user, products used).
Guardrails (must not degrade):
- Overall decline rate across all products.
- Non-Ultra completed volume per active user, to catch cannibalisation.
- Share of pre-launch active users who go silent for 14+ days, as a churn proxy.
- Crypto and other product volumes.
Threats to validity
| Threat | Mitigation |
|---|---|
| Selection bias: heavy users choose Ultra, so "subscribers transact more" is mostly pre-existing behaviour | Difference-in-differences against matched non-subscribers (same pre-period volume decile, tenure, country) |
| Seasonality (payday, holidays, travel) | Compare to the same window last year, or to a day-of-week-aligned pre-period |
| Marketing push inflates early adoption | Track adoption weekly, use any un-targeted region as a control, report the steady-state rate |
| Novelty effect | Judge by weeks 3 to 4, not the launch spike |
| Short window overstates lifetime value | Pre-commit to a day 30 to 60 second-payment check |
ultra events in activity that are not purchases | Base the primary metric on completed transactions only |
A randomised holdout, if one exists, beats all of the above.
SQL (primary and diagnostics)
WITH params AS (
SELECT TIMESTAMP '2024-03-01' AS launch_ts,
TIMESTAMP '2024-03-31' AS end_ts
),
eligible AS (
SELECT DISTINCT a.user_id
FROM activity a CROSS JOIN params p
WHERE a.event_time >= p.launch_ts - INTERVAL '30 days'
AND a.event_time < p.launch_ts
),
funnel AS (
SELECT a.user_id,
MAX(CASE WHEN event_type = 'view' THEN 1 ELSE 0 END) AS viewed,
MAX(CASE WHEN event_type = 'click' THEN 1 ELSE 0 END) AS clicked
FROM activity a CROSS JOIN params p
WHERE a.product = 'ultra'
AND a.event_time >= p.launch_ts AND a.event_time < p.end_ts
GROUP BY a.user_id
),
ultra_tx AS (
SELECT t.user_id,
MIN(CASE WHEN status = 'completed' THEN transaction_time END) AS first_paid,
SUM(CASE WHEN status = 'declined' THEN 1 ELSE 0 END) AS declines,
COUNT(*) AS attempts
FROM transactions t CROSS JOIN params p
WHERE t.product = 'ultra'
AND t.transaction_time >= p.launch_ts AND t.transaction_time < p.end_ts
GROUP BY t.user_id
)
SELECT COUNT(*) AS eligible_users,
AVG(CASE WHEN u.first_paid IS NOT NULL THEN 1.0 ELSE 0 END) AS adoption_rate,
SUM(COALESCE(f.viewed, 0)) AS viewers,
SUM(COALESCE(f.clicked, 0)) AS clickers,
COUNT(u.first_paid) AS payers,
SUM(u.declines)::numeric / NULLIF(SUM(u.attempts), 0) AS ultra_decline_rate
FROM eligible e
LEFT JOIN funnel f ON f.user_id = e.user_id
LEFT JOIN ultra_tx u ON u.user_id = e.user_id;
For the guardrail, compute each user's completed non-Ultra GBP volume in the 30 days before and after launch, split by subscriber vs. non-subscriber, and compare the average change between groups (difference-in-differences). Stratify by pre-period volume decile so regression to the mean is not mistaken for an effect.
Part B: Rule-based screening
Output choice
I output users with risk_score and reasons, because investigations, freezes and regulatory reports happen per customer. Each reason still traces back to specific transactions.
Rules (last 30 days)
| Rule | Logic | Weight | Typology |
|---|---|---|---|
| R1 Velocity | 10 or more completed transactions in any 1 hour | 3 | Account takeover, mule cash-out |
| R2 Card testing | 5 or more declines and decline ratio of at least 50% within 24 hours | 3 | Stolen card testing |
| R3 New account, high value | Account younger than 7 days with more than a set GBP total (for example 5,000) | 2 | Mule, synthetic identity |
| R4 Geo mismatch | ip_country differs from users.country, or several countries in a short window | 2 | Account takeover |
| R5 Structuring | Several amounts just under a reporting-style threshold | 2 | Structuring |
Thresholds are starting points, not truths.
SQL sketch
WITH tx AS (
SELECT * FROM transactions
WHERE transaction_time >= NOW() - INTERVAL '30 days'
),
r1 AS (
SELECT DISTINCT a.user_id
FROM tx a JOIN tx b
ON a.user_id = b.user_id
AND b.transaction_time BETWEEN a.transaction_time
AND a.transaction_time + INTERVAL '1 hour'
WHERE a.status = 'completed' AND b.status = 'completed'
GROUP BY a.user_id, a.transaction_id
HAVING COUNT(*) >= 10
),
r2 AS (
SELECT user_id FROM tx
GROUP BY user_id, DATE_TRUNC('day', transaction_time)
HAVING SUM(CASE WHEN status='declined' THEN 1 ELSE 0 END) >= 5
AND AVG(CASE WHEN status='declined' THEN 1.0 ELSE 0 END) >= 0.5
),
r3 AS (
SELECT t.user_id FROM tx t JOIN users u USING (user_id)
WHERE t.transaction_time < u.create_date + INTERVAL '7 days'
AND t.status = 'completed'
GROUP BY t.user_id
HAVING SUM(t.amount_gbp) > 5000
),
flags AS (
SELECT user_id, 'R1_velocity' AS rule, 3 AS w FROM r1
UNION ALL SELECT user_id, 'R2_card_testing', 3 FROM r2
UNION ALL SELECT user_id, 'R3_new_high_value', 2 FROM r3
)
SELECT user_id, SUM(w) AS risk_score, ARRAY_AGG(rule) AS reasons
FROM flags GROUP BY user_id
HAVING SUM(w) >= 3
ORDER BY risk_score DESC;
Trade-offs and iteration
- False positives waste analyst time and annoy legitimate customers (a salary payout or a traveller looks risky). False negatives let fraud or laundering through and carry regulatory risk. Set the score cut-off from analyst capacity and the relative cost of each error, and use tiers: auto-monitor, review, block.
- Evaluate with analyst-labelled outcomes: precision at the review threshold, hit rate per rule, and overlap between rules. Remove or down-weight rules with low precision; investigate known fraud that no rule caught to find gaps.
- Backtest on historical confirmed cases, then roll out in shadow mode before taking any action.
- Re-tune regularly, because fraudsters adapt. Once enough labels exist, use the rules as features for a supervised model while keeping the rules as an explainable baseline.
Common mistakes
- Using a post-launch denominator, or counting clicks as adoption without saying it is a proxy.
- Comparing subscribers to non-subscribers without accounting for selection.
- Having no guardrails, or guardrails that overlap with the primary metric.
- Outputting scores with no reasons, which makes the flags unusable for investigators.
- Treating thresholds as fixed instead of tuning them against labelled outcomes.