People do not leave jobs suddenly. They leave when staying no longer feels defensible.
The Exit Narrative Generator is a systems-level interpretability engine that transforms employee attrition data into coherent, human-readable narratives explaining why exit pressure accumulates, how stabilizing forces erode, and which small interventions could have plausibly changed the outcome.
This project is not a prediction engine. It is a post-hoc explanatory system designed to surface meaning, not alerts.
Exit-Narrative-Generator/
│
├── app/
│ └── app.py
│ # Streamlit application
│ # Interactive narrative report, peer context,
│ # dominant pressure visualization, and intervention builder
│
├── src/
│ ├── cli.py
│ │ # Command-line interface for data preparation,
│ │ # model training, and narrative export
│ │
│ ├── data_prep.py
│ │ # Data loading, cleaning, encoding, and
│ │ # feature normalization logic
│ │
│ ├── features.py
│ │ # Feature definitions and grouping
│ │ # (pressure vs retention anchor features)
│ │
│ ├── train_model.py
│ │ # Interpretable logistic regression training
│ │ # with transparent coefficient handling
│ │
│ ├── explain.py
│ │ # Per-employee contribution extraction
│ │ # (coefficient × feature value decomposition)
│ │
│ ├── narrative.py
│ │ # Narrative synthesis engine
│ │ # Converts numerical contributions into
│ │ # structured human-readable explanations
│ │
│ └── counterfactuals.py
│ # Counterfactual intervention logic
│ # Tests small, realistic changes to
│ # controllable features and ranks leverage
│
│
│
├── data/
│ └── HR-Employee-Attrition.csv
│ # Original dataset used for training and analysis
│
├── models/
│ └── attrition_model.joblib
│ # Trained interpretable model
│
├── reports/
│ └── narratives/
│ # (Optional) Exported narrative reports
│
├── requirements.txt
│ # Python dependencies
│
└── README.md
# Project documentation and conceptual explanation
-
app/Contains only presentation logic. No modeling decisions are hidden in the UI. -
src/Holds all analytical logic, making the system:- testable
- reusable
- auditable
-
Narrative logic is isolated (
narrative.py) so explanations are:- deterministic
- inspectable
- decoupled from modeling
-
Counterfactual reasoning is explicit (
counterfactuals.py) instead of embedded in UI logic.
This separation reinforces the project’s core principle:
Interpretability is an architectural decision, not a post-hoc feature.
This section documents the core views of the Exit Narrative Generator using real screenshots from the Streamlit application. Each view is explained not as a UI demo, but as a decision system that transforms attrition data into interpretable narratives and actionable counterfactuals.
The Narrative Report is the heart of the system. Instead of stopping at “P(exit) = 0.727”, the model translates statistical pressure into human-readable reasoning.
This view answers:
- Is attrition sudden or accumulated?
- Which forces are actively pushing the employee out?
- Which anchors are slowing that exit, even if they are insufficient?
-
Exit Probability A calibrated ML probability, used only as a signal, not a prediction.
-
Exit Narrative A synthesized explanation describing how pressure accumulates over time (overtime → fatigue → reduced recovery → rational exit).
-
Staying Narrative The counter-force story: what still ties the employee to the organization, and why those anchors may fail under sustained pressure.
This reframes attrition as a process, not an event.
Most attrition dashboards list features. This system separates forces by direction:
- Dominant Pressures → factors increasing exit likelihood
- Retention Anchors → stabilizers resisting exit
- Bar length = magnitude of contribution (log-odds space)
- Direction matters more than absolute value
- A strong anchor does not guarantee retention if opposing forces are stronger
This mirrors real systems: stability fails when opposing forces overwhelm buffers.
Attrition risk is meaningless without context.
This panel compares the selected employee only against true peers:
- Same department
- Same job role
- Same job level (when available)
An employee can:
- Have high exit risk but still be more stable than peers
- Or have moderate risk but be an outlier within their cohort
This avoids false alarms caused by population-wide pressure.
This is not a simulator of the future. It is a counterfactual search engine.
The system asks:
“If I could change one thing, which change reduces exit pressure the most?”
- Each row is a single-step intervention
- Ranked by Δ exit probability
- Reveals leverage, not certainty
This allows leaders to act where effort produces maximum stability gain.
Not all decisions should be automated.
This panel lets humans:
- Adjust levers manually
- Observe how probability responds
- Develop intuition about pressure sensitivity
It turns the model into a thinking tool, not a black box.
Traditional attrition models answer:
“Who will leave?”
Exit Narrative Generator answers:
- Why leaving becomes rational
- Which forces matter most
- Where intervention still works
- When optimization is already too late
It treats attrition as:
- A dynamic system
- Governed by pressure accumulation
- Stabilized by buffers
- Explained through narratives, not labels
Attrition is not an outcome. Attrition is a transition.
Most HR analytics systems fail because they treat resignation as a binary label instead of the final observable moment of a long, invisible process.
This project is built on one foundational claim:
By the time attrition is predicted with confidence, the system has already failed.
The Exit Narrative Generator focuses on the pre-collapse phase, the period where:
- pressure accumulates
- buffers erode
- recovery time disappears
- leaving becomes psychologically rational
Prediction assumes:
- the system is stationary
- interventions do not change dynamics
- accuracy improves decision quality
In reality:
- employees adapt
- managers react
- incentives shift
- culture responds
This makes attrition reflexive, not predictive.
Therefore, this system replaces:
“Who will leave?” with “Why does leaving make sense now?”
The Exit Narrative Generator models attrition as a force balance, not a probability:
Accumulated Exit Pressure
Remaining Retention Anchors
= Net Instability
- sustained overtime
- role life conflict
- stalled progression
- social isolation
- repeated identity resets (job changes)
- commute friction
- emotional exhaustion
- income security
- tenure inertia
- age-related risk aversion
- role familiarity
- geographic stability
- residual satisfaction pockets
Attrition does not occur when pressure exists. It occurs when anchors can no longer compensate.
This is the primary interpretive view of the system.
- understanding why an employee is at risk
- explaining decisions to managers
- reconstructing failures after the fact
- learning which pressures matter structurally
- firing decisions
- automated interventions
- ranking employees
A directional signal, not a promise. It answers:
“Is pressure currently dominating anchors?”
A qualitative state descriptor:
- “Exit narrative is forming”
- “Exit pressure dominates anchors”
- “Stability is fragile but intact”
This prevents false certainty.
A pressure-centric explanation, describing:
- how multiple weak signals aligned
- how recovery capacity eroded
- why continuing to stay feels increasingly irrational
This is not generated by an LLM. It is built from deterministic mappings between feature contributions and narrative templates.
A buffer-centric explanation, describing:
- what is still delaying exit
- why the employee has not yet left
- which anchors are weakening fastest
This avoids the false assumption that non-exit equals health.
Most explainability tools rank features by importance. This system separates them by direction.
These actively push the system toward exit:
- chronic overtime
- poor work life balance
- relationship dissatisfaction
- promotion stagnation
- frequent employer changes
These are accelerants, not triggers.
These slow exit but rarely reverse it:
- income relative to peers
- age-related stability
- tenure inertia
- geographic proximity
- role familiarity
Anchors delay collapse they do not prevent it.
This separation mirrors how humans reason:
“I know I should leave... but not yet.”
A salary number is meaningless without context. So is satisfaction. So is tenure.
Attrition is relative instability, not absolute dissatisfaction.
- defines a local comparison group
- normalizes metrics within role + department + level
- converts raw values into deviations
- Is this employee underpaid for their role?
- Is promotion delay structural or personal?
- Is dissatisfaction unique or systemic?
Without peer context, narratives become misleading.
The Intervention Builder does not suggest policies. It tests single-step counterfactuals.
Large hypothetical changes:
- break realism
- hide leverage
- create false hope
Small changes reveal:
- sensitivity
- leverage points
- asymmetries
The system:
- Perturbs one controllable variable
- Recomputes exit pressure
- Ranks changes by impact efficiency
This answers:
“What is the cheapest stabilizing action?”
Users can manually adjust:
- overtime
- satisfaction dimensions
- training exposure
- work life balance
This enables:
- manager-level reasoning
- policy stress-testing
- assumption validation
Optimization assumes:
- objectives are known
- constraints are stable
- systems respond linearly
Human systems do not.
This project intentionally avoids:
- automated recommendations
- global optimization
- KPI-driven control loops
Because optimization often borrows stability from the future.
- Logistic regression
- No hidden layers
- No embeddings
- No post-hoc explainers
- coefficients map directly to narratives
- explanations are stable
- behavior is reproducible
- reasoning is inspectable
This is not a performance race. It is an epistemic choice.
The Exit Narrative Generator operationalizes a simple but neglected truth:
By the time metrics collapse, the system has already crossed its point of no return.
This tool exists to surface:
- early pressure alignment
- anchor erosion
- narrative inevitability
Before resignation becomes inevitable.
- HR teams tired of dashboards without meaning
- Managers seeking explanations, not alerts
- Data scientists building interpretable systems
- Researchers studying failure as a process
- Anyone skeptical of prediction-first thinking
This is not HR analytics. This is systems analysis applied to human behavior.