Skip to content

Supplier Risk Radar: multi-regional supplier-risk analytics on CEPAL LAC-IOT 2011#1

Open
IMAbril wants to merge 6 commits into
mainfrom
claude/supplier-risk-portfolio-vqxl8z
Open

Supplier Risk Radar: multi-regional supplier-risk analytics on CEPAL LAC-IOT 2011#1
IMAbril wants to merge 6 commits into
mainfrom
claude/supplier-risk-portfolio-vqxl8z

Conversation

@IMAbril

@IMAbril IMAbril commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Supplier Risk Radar

EN — Complete portfolio data product: supplier / supply-chain risk analytics for a focal firm (default: a Brazilian motor-vehicle manufacturer), quantifying its hidden upstream exposure across 18 LAC countries × 40 sectors using the CEPAL LAC-IOT 2011 input-output table and a from-scratch linear-algebra engine.

ES — Producto de datos completo: analítica de riesgo de proveedores / cadena de suministro para una empresa focal (por defecto, una automotriz brasileña), cuantificando su exposición upstream oculta a través de 18 países de ALC × 40 sectores con la matriz insumo-producto CEPAL LAC-IOT 2011 y un motor de álgebra lineal hecho desde cero.

What's included / Contenido

  • src/supplier_risk/linalg.py — from-scratch LU with partial pivoting (vectorized elimination), hand-written forward/back substitution (no numpy.linalg.inv/solve, no scipy), matrix inverse and power method. Validated against numpy to ~4·10⁻¹⁵ at 720×720.
  • src/supplier_risk/io_model.py — CEPAL workbook → 720×720 multi-regional Z, technical coefficients A = Z·diag(1/x), Leontief inverse, npz/json cache. Documented data-cleaning guards (negative statistical adjustments, effectively-zero outputs); productivity validated via spectral radius (0.56 < 1).
  • src/supplier_risk/risk.py — upstream exposure (direct vs hidden), HHI concentration, Rasmussen backward/forward linkages, spectral centrality, composite 0–100 supplier risk score with exposure-gated systemic terms.
  • src/supplier_risk/scenarios.py — demand shocks (Δx = (I−A)⁻¹Δd), dual Leontief price model for cost shocks (Δp = (I−Aᵀ)⁻¹Δv), supply disruption, diversification with inverse rebuild.
  • app/dashboard.py — bilingual (EN/ES) Streamlit dashboard: exposure map, criticality quadrant, disruption simulator, diversification, risk-score explorer.
  • notebooks/case_study.ipynb — executed bilingual case study. Headline findings: 46% of upstream pull is hidden; country HHI 0.90; +30% BRA steel cost → +2.6% focal unit cost; re-sourcing half of steel to ARG/MEX cuts HHI to 0.80.
  • docs/metodologia.md, bilingual README, MIT LICENSE.

Validation / Validación

  • 49 tests passing (pytest -q): engine vs numpy, PA=LU reconstruction, pipeline sanity, metric bounds, scenario linearity/additivity, economic plausibility of the BRA auto chain.
  • scripts/build_cache.py validates the from-scratch Leontief inverse against numpy.linalg.inv on every build.
  • Dashboard verified headless with Playwright: all five tabs render in both languages without page errors.

Authorship / Autoría

The linear-algebra engine is adapted from the group academic project “Grupo 10 — Álgebra Lineal Computacional 2C 2024” (Abril Magali Ibarra, Santiago Roda), originally calcularLU / inversaLU / metodoPotencia in imabril/matrices_insumo-producto. Data: CEPAL/ECLAC LAC-IOT 2011.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR


Generated by Claude Code

claude added 6 commits July 2, 2026 05:26
- config.py: bilingual (EN/ES) taxonomy of the 18 LAC countries and 40
  sectors taken verbatim from the workbook Metadata sheet; focal-firm
  defaults (BRA, s30 Motor vehicles) and composite-score weights.
- linalg.py: from-scratch LU with partial pivoting, vectorized
  elimination, hand-written forward/back substitution (no scipy/numpy
  solvers), matrix inverse and power method. Core algorithms reused
  from the group project "Grupo 10 - Algebra Lineal Computacional
  2C 2024" (Abril Magali Ibarra, Santiago Roda), credited in the header.
- io_model.py: loads LAC_IOT_2011, assembles the 720x720 multi-regional
  Z, technical coefficients A = Z diag(1/x) (with guards for negative
  statistical adjustments and effectively-zero outputs) and the Leontief
  inverse via the from-scratch engine; npz/json cache for fast startup.
- scripts/build_cache.py validates the inverse against numpy (~4e-15)
  and checks productivity via spectral radius (0.56 < 1).
- 24 tests passing (LU/inverse/power method vs numpy; pipeline sanity).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
- upstream_exposure: Leontief-inverse column of the focal industry split
  into direct / hidden higher-order requirements, with country/sector
  aggregations and a country x sector pivot for heatmaps.
- hhi + concentration_summary: Herfindahl concentration of the upstream
  dependency by country, sector and individual supplier.
- rasmussen_indices (backward/forward linkages, key-sector flag) and
  spectral_centrality via the from-scratch power method on A^T,
  validated against numpy eigendecomposition.
- composite_risk_score: transparent weighted 0-100 blend of exposure,
  within-sector concentration, criticality and a country-risk proxy;
  criticality/country terms are relevance-gated by exposure so systemic
  hubs the firm does not buy from cannot top its supplier ranking.
- 14 tests passing (bounds, scale-invariance, plausibility of the BRA
  motor-vehicles chain, weight sensitivity, zero-exposure gating).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
- demand_shock: multi-regional generalization of the TP's
  variacion_demanda/variacion_produccion_* — recovers final demand from
  d = (I-A)x and propagates dx = (I-A)^-1 dd across all 720 industries.
- cost_shock: dual Leontief price model dp = (I-A^T)^-1 dv for unit-cost
  increases, solved with the from-scratch LU engine; focal_cost_impact
  helper reads the focal industry's cost pass-through.
- supply_disruption: converts a capacity loss in one supplier industry
  into focal dependency, exposure-at-risk and economy-wide output at risk.
- diversify: re-sources a fraction of the focal firm's direct input of a
  sector across alternative countries, rebuilds the Leontief inverse and
  reports before/after HHI and country exposure (input intensity kept).
- 11 tests passing (linearity, additivity, cross-country propagation,
  cost pass-through bounds, HHI reduction, column-sum preservation).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
Five views over the cached 720x720 Leontief model:
- Exposure map: KPI row (country/sector HHI, top-supplier and foreign
  shares), stacked direct-vs-hidden requirements of the top suppliers,
  and a country x sector heatmap of upstream exposure shares.
- Criticality: Rasmussen backward/forward quadrant with the focal
  firm's top-20 suppliers emphasized against a de-emphasized field.
- Disruption scenarios: cost (price model) or demand (quantity model)
  shocks with focal impact headline and most-impacted industries.
- Diversification: re-source an input sector across countries and
  compare before/after HHI and country exposure (inverse rebuilt live).
- Risk score: weight sliders and top-25 composite ranking with table.

Full ES/EN toggle; single-accent palette with sequential blue ramp
(validated with the dataviz palette checker); hover tooltips and table
views on every chart. Verified headless via Playwright: all five tabs
render without page errors in both languages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
Narrative report answering the business questions end to end: model
construction, upstream exposure map (46% of the focal firm's upstream
pull is hidden higher-order requirements; Argentina is the top foreign
dependency), concentration (country HHI 0.90) and Rasmussen/centrality
criticality, disruption scenarios (+30% BRA steel cost -> +2.6% focal
unit cost, two orders of magnitude above the same shock elsewhere;
+10% demand -> 1.76 output multiplier), diversification (re-sourcing
half of steel to ARG/MEX cuts country HHI 0.90 -> 0.80) and the
composite supplier risk score. All cells executed, outputs committed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
- README.md: full EN/ES project description, quick start, layout and an
  authorship section crediting the group project "Grupo 10 - Algebra
  Lineal Computacional 2C 2024" (Abril Magali Ibarra, Santiago Roda) as
  the origin of the linear-algebra engine, and CEPAL/ECLAC as the data
  source.
- docs/metodologia.md: bilingual methodology — data cleaning decisions,
  Leontief model and productivity condition (spectral radius 0.56),
  from-scratch engine provenance and validation, risk-metric formulas,
  scenario engine, limitations and reproducibility.
- LICENSE: MIT with the engine-provenance and data-source notice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaPtC5UKsvkXWiZcPuSyPR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants