Skip to content

Rollforward Workflow API Reference

Rollforward Workflow

cranalytics.rollforward_workflow

Canonical monthly Rollforward workflow orchestration.

RollforwardWorkflowResult dataclass

Workflow status and selected Rollforward model information.

run_rollforward_workflow(df, *, output_dir, holdout_months=6, min_train_months=12, step_months=1, variants=None, monitor_thresholds=None, amtloan_col='amtloan', segment=None, strict=False)

Run the canonical monthly Rollforward workflow and emit artifacts.

Rollforward Readiness

cranalytics.rollforward_readiness

Rollforward readiness report generation for onboarding trust signals.

generate_rollforward_readiness_report(*, input_csv, output_dir, holdout_months=6, min_train_months=6, segment=None, amtloan_col='amtloan', strict=False, scoring_config=None, weights=None)

Generate Rollforward readiness report artifacts.

Rollforward Contract

cranalytics.rollforward_contract

Public input-contract helpers for the Rollforward workflow.

RollforwardContractResult dataclass

Normalized rollforward data plus collected contract issues.

amtloan_map(*, segment=None)

Return resolved denominators as a segment->value mapping.

amtloan_series(*, segment=None)

Return resolved denominator series, optionally filtered to one segment.

has_issue_code(issue_code)

Return whether the collected issues include the requested code.

has_severity(severity)

Return whether the collected issues include the requested severity.

normalized_df(*, segment=None)

Return normalized rollforward data, optionally filtered to one segment.

validate_rollforward_input_contract(df, *, amtloan_col='amtloan', strict=False)

Normalize columns, resolve aliases, and collect rollforward data issues.

Rollforward Backtest

cranalytics.rollforward_backtest

Backtesting helpers for Rollforward workflow variants.

run_rollforward_backtest_sweeps(df, *, variants=None, holdout_horizons=(3, 6), min_train_months=12, step_months=1, amtloan_by_segment=None, amtloan_col='amtloan')

Run rolling OOT backtests across configured rollforward variants.

select_rollforward_champion_and_challengers(summary, *, benchmark_variant='baseline_flat_last_hazard', challenger_count=2)

Select a champion variant subject to baseline promotion rules.

summarize_rollforward_variant_performance(results)

Aggregate split-level rollforward backtest results to one row per variant.

Early Performance

cranalytics.early_performance

Early performance analytics utilities for event-rate and separation analysis.

calculate_early_performance_rates(df, flag_columns, weight_col=None, confidence=0.95)

Compute portfolio-level event rates and Wilson confidence intervals.

compute_conditional_loss_table(df, segment_cols, flag_col, outcome_col, n_bins_score=5, score_col=None, weight_col=None, confidence=0.95)

Compute conditional lifetime-loss summaries by segment, score bucket, and flag.

compute_marginal_impact(df, feature_col, flag_col, control_col, n_bins_control=5, n_bins_feature=None, weight_col=None)

Estimate feature effect within control strata via within-bucket rate deltas.

compute_segment_rates(df, flag_col, group_by, weight_col=None, n_bins=None, confidence=0.95)

Compute mature-event rates by segment(s) with volume and contribution shares.

compute_woe_iv(df, feature_col, flag_col, n_bins=10, weight_col=None)

Compute WoE/IV table and total IV for a single feature.

estimate_vintage_lifetime_profit(df, expected_loss_col, avg_life_col=None, avg_life=None, coupon_rate=0.0, servicing_cost_rate=0.0, funding_cost_rate=0.0)

Estimate vintage-level net margin from pricing assumptions and expected loss.

Formula::

net_margin = coupon_rate * avg_life
             - expected_loss_rate
             - servicing_cost_rate
             - funding_cost_rate

All rate inputs are decimals (e.g. 0.18 for 18%). avg_life is in years. coupon_rate is an annualised yield multiplied by avg_life to give the lifetime interest income. servicing_cost_rate and funding_cost_rate are lifetime rates (not annualised) and are subtracted directly without scaling by avg_life. expected_loss_rate is likewise a lifetime rate (e.g. from compute_conditional_loss_table).

Parameters

df : DataFrame with at least expected_loss_col (and optionally avg_life_col). expected_loss_col : Column of lifetime loss rates (decimals, e.g. 0.05 = 5%). avg_life_col : Per-row average life column (years). Takes precedence over avg_life. avg_life : Scalar average life (years) applied to all rows. Required if avg_life_col is None. coupon_rate : Annualised all-in yield (decimal); multiplied by avg_life in the formula. servicing_cost_rate : Lifetime servicing cost rate (decimal); not scaled by avg_life. funding_cost_rate : Lifetime cost-of-funds rate (decimal); not scaled by avg_life.

Returns

Copy of df with an added net_margin column.

rank_features_by_separation(df, feature_cols, flag_col, n_bins=10, weight_col=None)

Rank candidate features by IV, Gini, and KS against a binary target.

validate_performance_flags(df, flag_columns)

Validate binary flag columns and return maturity coverage statistics.