## NBA Recommendation & LLM Explainability

### Final NBA Output

Dataset: `nba_recommendation_features_final` - one row per recommended action per HCP.

**Key columns:**

- Identifiers: `hcp_id` · `hcp_name` · `specialty` · `territory` · 
  `city` · `state` · `practice_type` · `segment` · `account_tenure`
- Recommendation: `nba_recommendation` · `priority_tier` · 
  `engagement_tier` · `impact_tier`
- Scores: `engagement_probability` · `expected_impact` · 
  `expected_lift_pct` · `channel_cpa` · `channel_uplift`
- Prescribing: `avg_product_quantity_prescriptions` · 
  `prescriptions_last_week` · `prescriptions_last_4w_sum` · `rx_trend`
- Engagement history: `total_actions` · `total_successful_eng` · 
  `historical_success_rate` · `days_since_last_engagement` · 
  `previous_engagement_channel` · `sr_12w` · 
  `days_since_last_channel_attempt` · `days_since_last_channel_success`
- Per-channel successes: `rep_visit_engagement_successful_sum` · 
  `phone_call_engagement_successful_sum` · `email_engagement_successful_sum` · 
  `webinar_engagement_successful_sum` · `digital_ad_engagement_successful_sum`
- Explainability: `top_features_for_llm` (top 5 SHAP features as JSON) · 
  `llm_output` (parsed into HCP_ENGAGEMENT_SUMMARY / JUSTIFICATION_BULLETS / 
  REP_SUMMARY_PARAGRAPH)

### LLM Explainability for SHAP Values

**Problem**

Business roles do not understand log-odds contributions, feature names, or negative SHAP values. Raw model outputs cannot be surfaced to reps without translation.

**Approach**

An LLM recipe in Dataiku translates SHAP values and feature context into natural language. The recipe takes the top 5 SHAP features per recommendation and combines them with HCP profile, engagement history, and Rx data to generate three output sections per HCP.

**Benefits**

- **Trust**: reps understand why, not just what
- **Compliance**: transparent reasoning available for MLR review
- **Action**: explanations provide ready-to-use talking points for HCP 
  conversations
- **Debugging**: if the model makes an unexpected recommendation, the LLM 
  explanation surfaces the reason in plain language

### LLM Prompt Structure

**Input to LLM:**
- HCP profile: name · specialty · segment · territory · channel preference
- Recommendation: `nba_recommendation` · `engagement_probability` · 
  `engagement_tier` · `expected_lift_pct`
- Prescribing: `avg_product_quantity_prescriptions` · `rx_trend` · 
  `prescriptions_last_week`
- Engagement history: overall and per-channel success counts · 
  `days_since_last_engagement` · `previous_engagement_channel` · `sr_12w`
- Key drivers: `top_features_for_llm` (JSON — feature definition, 
  raw value, contribution strength, direction, narrative)

**Guardrails:**
- Do not mention SHAP, machine learning, AI, models, or optimization
- Do not claim causal impact or prescription lift
- Do not reference competitor products or other KindPharma products
- Use likelihood-based language: "more likely to engage", 
  "signals responsiveness", "projected to add"
- Respect driver direction: positive = supports recommendation, 
  negative = caution

**Output format - three sections:**

 1. `HCP_ENGAGEMENT_SUMMARY:` - 60–80 words covering commercial standing, engagement history, and prescribing profile. Does not reference the recommended channel.
 
 5. `JUSTIFICATION_BULLETS:` - 3–5 bullets grounded in SHAP driver values. Each bullet labelled Strong positive, Moderate positive, or Caution based on driver strength and direction.

 9. `REP_SUMMARY_PARAGRAPH:` - 60–100 word CRM-ready narrative explaining why this channel makes sense for this HCP right now. Usable directly in call preparation or CRM notes.