Predictive modelling

Inside PayPal: Predicting Declines and Choosing an Action

Study the authorization problem, request-time features and model choices before tracing how a predicted decline becomes a business decision.

Banking & PaymentsIndependent technical study

Source case: PayPal. The article separates the published design from the data, methods and observations in this local experiment.

Start with the issuer response, then define the decision

A shopper reaches checkout, but the issuer declines the authorization. The platform may investigate another funding source, additional authentication or a different customer experience. A useful prediction must eventually support a specific action whose benefits exceed its friction and cost.

PayPal’s 14 January 2021 article, CSV row 680, describes card-level response history, issuer patterns across card BINs and seller industries, and transaction timing. It compared Random Forest, GBM and neural networks, selecting GBM after its experiments. Decline predictions support tailored payment experiences. These are the published mechanisms; this independent study uses synthetic events and a small logistic model to investigate the reasoning behind an evaluation.

Study reconstruction separating authorization requests and issuer responses from decline prediction and an unexecuted intervention policy.Open full-size diagram (opens in a new tab)

Study reconstruction, not PayPal's original figure. Prediction estimates a response under the existing flow; an intervention needs separate evidence about incremental outcomes.

Design reference: PayPal Technology Blog, 14 January 2021

Make the model choice proportional to the learning question

Boosted trees are plausible for heterogeneous transaction data because interactions can matter: amount, issuer and recent response history may jointly describe a pattern that no single variable captures. Logistic regression provides a smaller additive baseline whose fitted coefficients and scaling can be inspected. Neither method is automatically superior without the relevant data and evaluation design.

The original experiment generated 5,400 attempts, trained on the first 3,240, selected thresholds on the next 1,080 and evaluated on the last 1,080. Its seven features are log amount, night, weekend, two issuer indicators and prior card/issuer decline rates. It actually fitted regularized logistic regression; a constant training-prior predictor is the baseline.

The generator is mostly additive in log-odds and therefore deliberately compatible with that small model family. Its labels are issuer responses, not fraud or intervention effects. The fixed model is useful here because its numerical behaviour is understandable; this does not establish a model-family winner for real payments.

The connected pipeline copies the original events and fitted slice without changing them. An instrumented copy of the original generator exposes the probability used for each response draw. Every event identity, feature and observed label is checked against the original 5,400-row file. Those probabilities stay outside training and inference. They are a diagnostic privilege, including latent generator state that a real modeller would not know.

Derive what the fixed rule needs to achieve

The illustrative loss is FP + 6 × FN: one arbitrary unit for a false review flag and six for a missed decline. A correct flag is assigned zero cost. That assumption is deliberately visible; an actual intervention would have processing costs and an uncertain chance of rescuing the payment.

At the original 0.10 threshold, the model flags two declines and twenty-four approved events, missing sixty-three declines. Relative to flagging nothing, the extra cost is 24 − 6 × 2 = 12: 402 instead of 390. The flagged group’s precision must exceed 1/7, or 14.3%, to break even. Its observed 7.7% does not.

If probabilities were calibrated and correct actions had zero cost, expected-loss comparison gives (1 − p) < 6p, hence a theoretical cutoff of p > 1/7. The empirical validation procedure choosing 0.10 is not a mathematical bug. That earlier window had eight true positives and thirty-five false positives, saving thirteen units under the same loss. No threshold is reselected after examining the final window.

Average precision improved from 0.060 to 0.091 and Brier score from 0.0570 to 0.0563. Those describe discrimination and probability error, not whether this specific flagging policy is worthwhile. AUROC is not mathematically inflated by prevalence alone; the operational issue is that a small false-positive rate can still create many false flags when declines are rare. Precision and volume must accompany the operating point.

Use the known generator to interrogate the apparent failure

The new diagnosis holds the observed request histories, scores and original threshold fixed. For each request, its known generator probability gives the conditional expected loss of flagging or not flagging. Summing these one-step losses gives 367.42 units for no flags and 362.58 for the model rule: a modest expected advantage of 4.85 units on those realized histories.

Compute one-step expected losses without changing the model or rulePython6 lines
def conditional_losses(rows, flags):
    """One-step expected teaching losses on the observed request histories."""
    baseline = sum(6 * row["generation_probability"] for row in rows)
    policy = sum((1 - row["generation_probability"]) if flag else 6 * row["generation_probability"]
                 for row, flag in zip(rows, flags))
    return {"no_flags": baseline, "model": policy, "delta": policy - baseline}

The twenty-six flagged requests have mean predicted probability 12.06%, known generator probability 16.95%, and observed decline frequency 7.69%. The observed frequency alone makes the tail look overpredicted. In this synthetic world, however, the predictor underestimates the mean response probability of that group. Only two outcomes happened to be declines.

This does not invalidate the observed cost. It changes the explanation: an unfavourable realization need not mean that the rule had unfavourable conditional expected loss. With real data, the generator column would not exist, so a twenty-six-request calibration bin could not settle that question. The lesson is to preserve uncertainty instead of treating its empirical frequency as a precise truth.

Observed extra cost is plus 12; one-step expected extra cost is minus 4.85; simulated response paths average minus 3.83 with a minus 28 to plus 17 fifth-to-ninety-fifth-percentile range.Open full-size figure (opens in a new tab)
Actual derived results from the frozen teaching rule. Negative values favour the model rule under the assumed loss. The simulation range is conditional on the authored response process, not a real-world confidence interval.

Resample response paths without freezing histories that should change

Simply redrawing test labels while leaving every future history unchanged would break the temporal process. A different response becomes part of the next request’s card and issuer features.

The new experiment therefore preserves the original pre-test history and the exogenous test request sequence, then generates 200 alternative test response paths using the same response equation. Each path updates its own rolling histories before the next prediction. Model coefficients and the original threshold remain fixed. This is a retrospective sensitivity exercise, not a search for a better policy.

The average extra cost is −3.83 units, but 44% of paths cost more than flagging nothing. The fifth-to-ninety-fifth percentile range is −28 to +17 units. These are properties of the specified simulator and request sequence. They do not estimate a bank’s financial uncertainty or prove that the real deployment would improve conversion.

The practical conclusion is restrained: the rule’s advantage is small relative to response-path variation. An observed loss and a modest expected benefit can coexist. Neither justifies changing the recorded result or claiming a robust operational win.

Check the data path before trusting a more complex model

The next link in the chain asks what those historical rates actually knew. The original process assumes earlier issuer responses are immediately visible. The Faire study now takes these same event identities, adds explicit response-arrival times, builds two training histories and compares actual fitted models on identical available-time future inputs. The oracle probabilities never enter that work.

The Pinterest study then uses the available-history model and those source events to execute scoring and logging around a real local feature refresh. These are three views of one engineering problem, not three unrelated production models.

For a real payment objective, the missing piece remains action effectiveness. Decline probability under the current flow cannot identify which authentication or alternative-payment action increases completion. A later authorized policy experiment would need incremental completion, friction and cost, with mature outcomes. The current chain strengthens the evidence about prediction and feature handling without inventing those causal results.

Inspect the new diagnosis and the unchanged original experiment

Recorded experiment

What the experiment actually shows

Connected study 04: diagnose a frozen policy, with known synthetic probabilities kept outside all model inputs.

Data and comparison boundary

Methods compared

Observed teaching cost
Original threshold 0.10, false flag=1 and missed decline=6.
Generator-based diagnosis
Use the author's known response equation to distinguish realized label noise from expected one-step loss; not a deployable oracle.

Recorded findings

Observed extra cost vs no flags
+12

The unchanged original outcome remains 402 versus 390.

One-step expected extra cost
-4.845

Summed conditional losses on the realized histories; not a real-world expected profit estimate.

Simulated path delta: mean / 5–95% range
-3.825 / -28 to 17

Conditional simulator exercise; 44% of the 200 paths cost more. Not a financial confidence interval.

Inspect a recorded example

Same rule, observed versus conditional expected loss
Input

Original 1,080 test requests; original weights and threshold, not selected again.

Baseline output

{ "observed_no_flags": 390, "one_step_expected_no_flags": 367.42211729345445 }

Candidate output

{ "observed_model": 402, "one_step_expected_model": 362.577068417476 }

These are saved results. Switching examples runs no model or external service.

Limits of this experiment

  • All outcomes and cost assumptions are synthetic.
  • The response-path experiment fixes the original training/validation history and test request sequence; it is not an unconditional rerun of an entire financial population.
  • The original threshold is never tuned on the test window; the 200 paths are a retrospective sensitivity exercise.
Inspect the recorded provenance
{
  "lineage": {
    "parents": {
      "engineering-lab/paypal/study.py": "20366589609101ef48e6920b35d760762869e5c24d3a07a7678adba6b7467a24",
      "engineering-lab/paypal/events.csv": "5b5829abf4bd3d92aa5b748a7339b7ca5f59c0e6063cf4bed6afb5ca50a388b4",
      "engineering-lab/paypal/results.json": "f9c9fd30f11c897cb7801a5d22bf91122026cd3fef5934a929f87cad2db2dd59"
    },
    "model_selector": "/provenance/fitted_model",
    "original_threshold": 0.1,
    "feature_names": [
      "log_amount",
      "night",
      "weekend",
      "issuer_1",
      "issuer_2",
      "prior_card_decline_rate",
      "prior_issuer_decline_rate"
    ],
    "boundary": "The original model/events remain unchanged. Oracle probabilities are recovered only for diagnosis, never passed to fitting or inference. New delayed-arrival features and two new fits are separate artifacts.",
    "original_model_slice_sha256": "ed55b7a21697107f3f8305652b03933088de1f0322bc430e7146f2cbc7122f5d"
  },
  "configuration": {
    "data_kind": "Fully synthetic teaching process, not PayPal or public payment data",
    "seed": 680,
    "days": 90,
    "events_per_day": 60,
    "cards": 80,
    "train_before_day": 54,
    "validation_before_day": 72,
    "epochs": 240,
    "learning_rate": 0.15,
    "l2": 0.01,
    "false_flag_cost_units": 1,
    "missed_decline_cost_units": 6,
    "generator_note": "Issuer response is sampled from an authored process with latent card stress, amount, issuer, hour and past response effects. Issuer group 1 has a declared log-odds shift of +0.8 from day 72. This is a teaching distribution shift, not an observed banking phenomenon.",
    "decision_note": "A positive model flag is an offline review label, not a decision to decline, retry or authenticate a real payment. Costs are arbitrary error units, not euros or revenue.",
    "simulation_paths": 200,
    "simulation_seed": 20261201,
    "response_delay": {
      "ordinary_seconds": 60,
      "issuer_1_seconds": 10800,
      "every_5th_seconds": 1800,
      "every_11th_seconds": 129600
    },
    "capture_refresh_seconds": 3600
  },
  "frozen_files": {
    "core.py": "89322a65b8653f94ff75e7267396f36de292a634578c9038833bef4fd1c2b681",
    "generator.py": "f8c792da18196efdd35fa40ab6b135df608d287ec57e3a5aebb4ae92b0628739",
    "model_math.py": "9f861dc4a95f7a77156470299488bdb1700935f8241b4bcd16bda6d807bad907",
    "payment.py": "6ae540f3a7d59699b40f34e8d8de2f10d9e848761ff034919cd2526754f89510",
    "features.py": "7fd0f54fa7f3047ac0eb2d04c0be3f0be59ec108037264573d9d60a3ec2c4480",
    "capture.py": "f0688fc49b8396190dd8d3e30c2325da30e3e72cebdf5db284c6c3a3c9273abe",
    "run.py": "7b0d22dd65893d652a525c47d5c6b0055dcb2949503edfc8f32e92365e3b0adb",
    "verify.py": "4c6dd9cadc8b071303e8c68484e451e5d8b4cf4fa77e058209d4daf0381e89b2",
    "config.json": "15a90fb85fd2208e59a1b9d40cdc350fef565c33b16eab085f1ac5d0ffae7d20",
    "lineage.json": "920831837f2cf112b4acef66ca51c787686d3c6de0aa5f246621077462ac2bbc",
    "sources.json": "981a1730e67f6de647613927cffe98ed9bf1bc76cb0c36fd7a55358f74d15011",
    "source-events.csv": "5b5829abf4bd3d92aa5b748a7339b7ca5f59c0e6063cf4bed6afb5ca50a388b4",
    "original-model.json": "79fbfef4d60f37c270af0bae1b12949a2baed6ca18e9216251b5f0073ae428bc"
  },
  "observation": {
    "matched_original_events": 5400,
    "threshold": 0.1,
    "observed": {
      "tp": 2,
      "fp": 24,
      "fn": 63,
      "tn": 991,
      "threshold": 0.1,
      "cost_units": 402
    },
    "observed_no_flags": 390,
    "conditional_expected_no_flags": 367.42211729345445,
    "conditional_expected_model": 362.577068417476,
    "conditional_expected_delta": -4.845048875978421,
    "calibration_bins": [
      {
        "low": 0,
        "high": 0.02,
        "count": 36,
        "mean_prediction": 0.01755136548029548,
        "oracle_mean": 0.013817228860869675,
        "observed_rate": 0
      },
      {
        "low": 0.02,
        "high": 0.05,
        "count": 677,
        "mean_prediction": 0.03415711730275854,
        "oracle_mean": 0.040731288885735906,
        "observed_rate": 0.047267355982274745
      },
      {
        "low": 0.05,
        "high": 0.1,
        "count": 341,
        "mean_prediction": 0.06542698473836484,
        "oracle_mean": 0.08433454891660819,
        "observed_rate": 0.09090909090909091
      },
      {
        "low": 0.1,
        "high": 1,
        "count": 26,
        "mean_prediction": 0.12055902223944612,
        "oracle_mean": 0.16947829052735466,
        "observed_rate": 0.07692307692307693
      }
    ],
    "simulation": {
      "paths": 200,
      "mean_delta": -3.825,
      "p05_delta": -28,
      "median_delta": -2,
      "p95_delta": 17,
      "fraction_model_more_costly": 0.44,
      "deltas": [
        -18,
        -8,
        2,
        -12,
        2,
        -8,
        -10,
        -21,
        4,
        11,
        15,
        -27,
        7,
        -16,
        1,
        0,
        -9,
        -25,
        5,
        -15,
        2,
        14,
        4,
        -38,
        -7,
        -7,
        -22,
        -10,
        4,
        18,
        0,
        -11,
        -23,
        0,
        8,
        13,
        -38,
        12,
        2,
        -7,
        14,
        -9,
        1,
        -38,
        -18,
        -5,
        -2,
        -8,
        -6,
        10,
        10,
        -14,
        -61,
        7,
        16,
        7,
        10,
        -2,
        -4,
        -9,
        -11,
        3,
        -11,
        -11,
        4,
        17,
        -18,
        -19,
        3,
        -1,
        -31,
        1,
        -6,
        24,
        -40,
        -19,
        -8,
        -7,
        -21,
        20,
        -14,
        6,
        3,
        19,
        -14,
        -21,
        1,
        -31,
        -13,
        5,
        1,
        10,
        15,
        -30,
        -27,
        12,
        2,
        -12,
        -6,
        5,
        -2,
        -2,
        -14,
        18,
        -9,
        12,
        -7,
        -5,
        -10,
        1,
        23,
        29,
        3,
        9,
        -14,
        -12,
        2,
        -10,
        8,
        6,
        12,
        0,
        -6,
        5,
        7,
        -7,
        4,
        -26,
        -28,
        -5,
        -14,
        -10,
        -6,
        -9,
        -28,
        -3,
        -5,
        -17,
        -6,
        -15,
        -2,
        -9,
        -21,
        -2,
        11,
        -19,
        6,
        4,
        4,
        3,
        -2,
        6,
        19,
        -9,
        15,
        -8,
        -27,
        -8,
        2,
        -7,
        3,
        -8,
        3,
        12,
        -16,
        1,
        10,
        7,
        18,
        -41,
        -2,
        -17,
        6,
        -2,
        2,
        -14,
        -6,
        12,
        1,
        -14,
        -13,
        -10,
        -11,
        16,
        16,
        19,
        -4,
        -2,
        9,
        -11,
        -25,
        -57,
        10,
        9,
        4,
        1,
        17,
        7,
        9,
        0
      ],
      "boundary": "Conditional response-path exercise: preserve original pre-test history and exogenous test requests; regenerate test responses with the same equation, updating each path's histories. Not a real-world confidence interval."
    }
  }
}

The following record is the original experiment, retained unchanged. Its unfavourable realized cost remains part of the evidence.

Recorded experiment

What the experiment actually shows

Independent standard-library modelling study using fully synthetic payment-attempt teaching data; no real payments or PayPal integration.

Data and comparison boundary

Methods compared

Constant training prior
Every request receives the training decline frequency; tied scores are handled as one AP threshold.
Logistic regression
Actually fitted with batch gradient descent on amount, time, issuer and strictly earlier response-history features.

Recorded findings

Test decline prevalence
6.02%

Synthetic issuer responses; test period contains the declared distribution shift.

Average precision: prior → logistic
0.060 → 0.091

Ranking performance on this one generated process, not real payment authorization performance.

Brier score: prior → logistic
0.0570 → 0.0563

Probability error; inspect calibration bins and observed rates as well.

Toy error cost: prior → logistic
390 → 402

Validation-selected thresholds; false flag=1 and missed decline=6 arbitrary cost units. No money or causal payment benefit.

Inspect a recorded example

Highest model score
Input

{ "event_id": 4503, "date": "2026-03-21", "amount": 321.5, "issuer": 2, "hour": 1, "declined": 0 }

Baseline output

{ "probability": 0.038580246913580245, "threshold": 1.0 }

Candidate output

{ "probability": 0.21739428781482742, "threshold": 0.1, "prior_card_decline_rate": 0.10714285714285714 }

These are saved results. Switching examples runs no model or external service.

Limits of this experiment

  • All records, labels, history effects and the test shift come from an authored generator; no actual authorization or fraud data is used.
  • Decline does not mean fraud, and an approved response does not establish a safe customer.
  • Past issuer responses are assumed immediately visible; settlement, challenge outcomes and interventions are not modelled.
  • The same cards recur across time. This is a future-event diagnostic, not new-customer generalization.
  • Error-cost units are assumptions. No retry, authentication, payment block or uplift experiment is executed.
Inspect the recorded provenance
{
  "config": {
    "data_kind": "Fully synthetic teaching process, not PayPal or public payment data",
    "seed": 680,
    "days": 90,
    "events_per_day": 60,
    "cards": 80,
    "train_before_day": 54,
    "validation_before_day": 72,
    "epochs": 240,
    "learning_rate": 0.15,
    "l2": 0.01,
    "false_flag_cost_units": 1,
    "missed_decline_cost_units": 6,
    "generator_note": "Issuer response is sampled from an authored process with latent card stress, amount, issuer, hour and past response effects. Issuer group 1 has a declared log-odds shift of +0.8 from day 72. This is a teaching distribution shift, not an observed banking phenomenon.",
    "decision_note": "A positive model flag is an offline review label, not a decision to decline, retry or authenticate a real payment. Costs are arbitrary error units, not euros or revenue."
  },
  "config_sha256": "241586858d332c4c969a4a9ab497fc6cb5e280ca644ceb294c78827f0c65ea94",
  "source_sha256": "20366589609101ef48e6920b35d760762869e5c24d3a07a7678adba6b7467a24",
  "events_sha256": "5b5829abf4bd3d92aa5b748a7339b7ca5f59c0e6063cf4bed6afb5ca50a388b4",
  "split_counts": {
    "train": 3240,
    "validation": 1080,
    "test": 1080
  },
  "feature_names": [
    "log_amount",
    "night",
    "weekend",
    "issuer_1",
    "issuer_2",
    "prior_card_decline_rate",
    "prior_issuer_decline_rate"
  ],
  "fitted_model": {
    "weights": [
      -3.2745746770625868,
      0.21532022915617038,
      0.19283168859324532,
      0.14976541130067123,
      -0.00690757535505301,
      0.19345136122661916,
      0.1438474870455266,
      0.11843698286018924
    ],
    "means": [
      3.913132781187582,
      0.24876543209876542,
      0.25925925925925924,
      0.34382716049382717,
      0.31820987654320987,
      0.048036606003084015,
      0.0403849495067627
    ],
    "scales": [
      0.8869451050123058,
      0.4322975733120477,
      0.4382281320814461,
      0.4749842567923577,
      0.4657814412506826,
      0.018069860538928353,
      0.01973369541602219
    ],
    "training_prior": 0.038580246913580245
  },
  "test_metrics": {
    "constant_prior": {
      "events": 1080,
      "declines": 65,
      "observed_rate": 0.06018518518518518,
      "mean_prediction": 0.03858024691358035,
      "average_precision": 0.06018518518518518,
      "brier": 0.05702970202712884,
      "log_loss": 0.23287991377292946,
      "calibration_bins": [
        {
          "lower": 0,
          "upper": 0.02,
          "count": 0,
          "mean_prediction": null,
          "decline_frequency": null
        },
        {
          "lower": 0.02,
          "upper": 0.05,
          "count": 1080,
          "mean_prediction": 0.03858024691358035,
          "decline_frequency": 0.06018518518518518
        },
        {
          "lower": 0.05,
          "upper": 0.1,
          "count": 0,
          "mean_prediction": null,
          "decline_frequency": null
        },
        {
          "lower": 0.1,
          "upper": 0.2,
          "count": 0,
          "mean_prediction": null,
          "decline_frequency": null
        },
        {
          "lower": 0.2,
          "upper": 1,
          "count": 0,
          "mean_prediction": null,
          "decline_frequency": null
        }
      ],
      "decision": {
        "tp": 0,
        "fp": 0,
        "fn": 65,
        "tn": 1015,
        "threshold": 1,
        "cost_units": 390
      }
    },
    "logistic": {
      "events": 1080,
      "declines": 65,
      "observed_rate": 0.06018518518518518,
      "mean_prediction": 0.04555680920857979,
      "average_precision": 0.09064381195615352,
      "brier": 0.05630538054980963,
      "log_loss": 0.2249138963110413,
      "calibration_bins": [
        {
          "lower": 0,
          "upper": 0.02,
          "count": 36,
          "mean_prediction": 0.01755136548029548,
          "decline_frequency": 0
        },
        {
          "lower": 0.02,
          "upper": 0.05,
          "count": 677,
          "mean_prediction": 0.03415711730275854,
          "decline_frequency": 0.047267355982274745
        },
        {
          "lower": 0.05,
          "upper": 0.1,
          "count": 341,
          "mean_prediction": 0.06542698473836484,
          "decline_frequency": 0.09090909090909091
        },
        {
          "lower": 0.1,
          "upper": 0.2,
          "count": 25,
          "mean_prediction": 0.11668561161643089,
          "decline_frequency": 0.08
        },
        {
          "lower": 0.2,
          "upper": 1,
          "count": 1,
          "mean_prediction": 0.21739428781482742,
          "decline_frequency": 0
        }
      ],
      "decision": {
        "tp": 2,
        "fp": 24,
        "fn": 63,
        "tn": 991,
        "threshold": 0.1,
        "cost_units": 402
      }
    }
  },
  "source": {
    "csv": {
      "logical_row_including_header": 680,
      "title": "Using Machine Learning to Improve Payment Authorization Rate",
      "original_url": "https://medium.com/paypal-tech/using-machine-learning-to-improve-payment-authorization-rates-bc3b2cbf4999"
    },
    "primary": {
      "url": "https://medium.com/paypal-tech/using-machine-learning-to-improve-payment-authorization-rates-bc3b2cbf4999",
      "published": "2021-01-14",
      "checked": "2026-12-01",
      "adapted_mechanisms": [
        "Issuer decline is different from fraud",
        "Use past card/issuer response patterns and transaction-time features",
        "Evaluate the rare decline class with precision-recall analysis"
      ],
      "boundary": "PayPal reports a production GBM system. This independent study fits logistic regression to an authored synthetic process and executes no payment intervention."
    },
    "data_rights": "All events, labels, IDs and cost assumptions are authored synthetic teaching data. No actual card, account, merchant, customer or private PayPal data is included."
  },
  "execution": "Deterministic local Python computation; no LLM, external model, API call or model weights."
}

In engineering-lab/payment-pipeline, run python3 run.py and python3 verify.py. The commands reproduce the event checks, response-path exercise, two feature-history fits and actual capture runs. All source slices, configurations and output views are fingerprinted. No model API is used.