# FINAL PROJECT DOCUMENTATION
## AstraZeneca Cash Flow Forecasting - Datathon 2025

**Project Completion Date:** December 19, 2025  
**Status:** ✅ All Deliverables Complete

---

## 📋 **TABLE OF CONTENTS**

1. [Project Overview](#project-overview)
2. [Deliverables Checklist](#deliverables-checklist)
3. [Methodology Summary](#methodology-summary)
4. [Key Results](#key-results)
5. [File Structure](#file-structure)
6. [How to Use](#how-to-use)

---

## 🎯 **PROJECT OVERVIEW**

### **Objective**
Build a reliable cash flow forecasting model for AstraZeneca's multi-entity operations, providing 6-month weekly forecasts with confidence intervals and actionable business insights.

### **Approach**
1. **Model Selection:** Compare 3 models, select best performer (Prophet)
2. **Validation:** Triple-validate using multiple approaches
3. **Production Forecast:** Generate 6-month forecast with uncertainty quantification
4. **Analysis:** Deep-dive into categories (AR/AP) and entities
5. **Visualization:** Create comprehensive dashboards
6. **Recommendations:** Provide actionable business insights

---

## ✅ **DELIVERABLES CHECKLIST**

### **Required Deliverables**

#### ✅ **1. Data Understanding & Transformation**
- [x] Dataset explanation documented
- [x] Transformation steps explained
- [x] Data quality report generated
- **Files:** `data_cleaning.py`, `data_cleaned_weekly.csv`

#### ✅ **2. Dashboard Presentation**
- [x] Cash inflow/outflow visualizations
- [x] AstraZeneca color theme applied
- [x] Accessible and clearly labeled
- **Files:** `dashboard/` directory (12 dashboards)

#### ✅ **3. Pattern Analysis**
- [x] Actual vs forecasted data visualized
- [x] Trends and patterns identified
- [x] Category-level patterns analyzed
- **Files:** Multiple dashboard files

#### ✅ **4. Forecasting** ⭐ **CORE REQUIREMENT**
- [x] Weekly net cash flow forecast (26 weeks)
- [x] Weekly ending cash balance forecast (26 weeks)
- [x] Forecast vs actual comparison
- [x] At least 2 categories explained (AR & AP)
- [x] Model choice, assumptions, and drivers documented
- [x] Metrics evaluated (MAE, RMSE, MAPE)
- **Files:** `FORECAST_OUTPUT_FINAL.csv`, `FORECAST_OUTPUT_REPORT.md`

#### ✅ **5. Anomaly Detection**
- [x] Duplicate transactions identified
- [x] Unusual spikes/drops flagged
- [x] Out-of-pattern transactions detected
- **Files:** `data_with_anomaly_flags.csv`, `data_flagged_duplicate_transactions.csv`

#### ✅ **6. Cash Flow Analysis**
- [x] Category-level trends analyzed
- [x] Entity-level and consolidated views
- [x] Short-term liquidity risks assessed
- [x] Long-term sustainability patterns identified
- **Files:** `category_analysis_summary.csv`, `business_recommendations.csv`

---

## 📊 **METHODOLOGY SUMMARY**

### **Phase 0: Model Selection**
- **Script:** `00_model_comparison.py`
- **Models Tested:** Moving Average, Exponential Smoothing, Prophet
- **Result:** Prophet selected (MAE: $2.24M vs $3.72M vs $4.80M)
- **Output:** `model_comparison_results.csv`, `dashboard/00_model_comparison.png`

### **Phase 1: Option A - Forward Validation**
- **Script:** `01_forecast_option_a.py`
- **Method:** Train on weeks 1-39, test on weeks 40-44
- **Result:** 60% direction accuracy, $2.24M MAE
- **Output:** `option_a_predictions.csv`, `VALIDATION_OPTION_A_REPORT.md`

### **Phase 2A: Option B1 - Rolling Window Validation**
- **Script:** `02_forecast_option_b1.py`
- **Method:** Multiple rolling windows (1-4 month horizons)
- **Result:** Gradual degradation (1M: $1.36M, 4M: $1.91M)
- **Output:** `option_b1_results.csv`, `VALIDATION_OPTION_B1_REPORT.md`

### **Phase 2B: Option B2 - Monthly Cross-Validation**
- **Script:** `03_forecast_option_b2.py`
- **Method:** Within-month 80/20 splits for 10 months
- **Result:** Average MAE $9.89M, moderate consistency
- **Output:** `option_b2_results.csv`, `VALIDATION_OPTION_B2_REPORT.md`

### **Phase 3: Option C - Production Forecast**
- **Script:** `04_forecast_option_c_production.py`
- **Method:** Train on all 44 weeks, forecast 26 weeks
- **Result:** 6-month forecast with confidence intervals
- **Output:** `FORECAST_OUTPUT_FINAL.csv` ⭐ **MAIN DELIVERABLE**

### **Phase 4: Category Deep-Dive**
- **Script:** `06_category_deep_dive.py`
- **Focus:** AR and AP analysis
- **Result:** AR drives 85% inflows, Netting AP drives 52% outflows
- **Output:** `category_analysis_summary.csv`, `ar_forecast_26weeks.csv`, `ap_forecast_26weeks.csv`

### **Phase 5: Executive Dashboard**
- **Script:** `08_executive_dashboard.py`
- **Content:** Consolidated view of all insights
- **Output:** `dashboard/08_executive_dashboard.png`

### **Phase 7: Analysis & Recommendations**
- **Script:** `09_analysis_recommendations.py`
- **Content:** 10 actionable recommendations
- **Output:** `business_recommendations.csv`, `dashboard/09_analysis_recommendations.png`

---

## 🎯 **KEY RESULTS**

### **Model Performance**
- **Direction Accuracy:** 60% (better than random 50%)
- **Average MAE:** $1.84M per week
- **Threshold MAPE:** 30.7% (when |actual| > $1M)
- **CI Coverage:** 86% (well-calibrated)

### **6-Month Forecast**
- **Net Cash Flow:** +$5.45M (most likely)
- **Ending Balance:** $11.19M (from $9.65M starting)
- **Best Case:** $104.1M ending balance
- **Worst Case:** -$83.3M ending balance
- **Liquidity Status:** ✅ HEALTHY (no negative weeks)

### **Category Insights**
- **AR:** $107.2M (85% of inflows) → Forecast: +$77.5M
- **AP:** -$38.6M (31% of outflows) → Forecast: -$29.4M
- **Netting AP:** -$64.2M (52% of outflows)

### **Entity Insights**
- **Best:** TW10 (+$1.8M), VN20 (+$3.5M)
- **Monitor:** KR10 (-$1.1M), MY10 (-$1.6M)

---

## 📁 **FILE STRUCTURE**

```
Datathon_2025/
├── 📊 DATA FILES
│   ├── data_cleaned_weekly.csv (main input)
│   ├── data_cash_balance_processed.csv
│   ├── FORECAST_OUTPUT_FINAL.csv ⭐ MAIN DELIVERABLE
│   └── ending_balance_forecast.csv
│
├── 📈 ANALYSIS FILES
│   ├── accuracy_summary.csv
│   ├── category_analysis_summary.csv
│   ├── business_recommendations.csv
│   ├── ar_forecast_26weeks.csv
│   └── ap_forecast_26weeks.csv
│
├── 📝 DOCUMENTATION
│   ├── EXECUTIVE_SUMMARY.md
│   ├── ACCURACY_REPORT.md
│   ├── PROBLEM_STATEMENT.md
│   ├── FORECAST_OUTPUT_REPORT.md
│   ├── VALIDATION_OPTION_A_REPORT.md
│   ├── VALIDATION_OPTION_B1_REPORT.md
│   └── VALIDATION_OPTION_B2_REPORT.md
│
├── 🐍 PYTHON SCRIPTS
│   ├── data_cleaning.py
│   ├── 00_model_comparison.py
│   ├── 01_forecast_option_a.py
│   ├── 02_forecast_option_b1.py
│   ├── 03_forecast_option_b2.py
│   ├── 04_forecast_option_c_production.py ⭐ MAIN SCRIPT
│   ├── 05_accuracy_analysis.py
│   ├── 06_category_deep_dive.py
│   ├── 07_improved_mape_metrics.py
│   ├── 08_executive_dashboard.py
│   └── 09_analysis_recommendations.py
│
└── 📊 DASHBOARDS (dashboard/)
    ├── 00_model_comparison.png
    ├── 01_option_a_validation.png
    ├── 02_option_b1_rolling_validation.png
    ├── 02_option_b1_degradation_analysis.png
    ├── 03_option_b2_monthly_validation.png
    ├── 04_option_c_production_forecast.png ⭐ MAIN DASHBOARD
    ├── 04_entity_forecasts.png
    ├── 04_category_forecasts.png
    ├── 04_liquidity_risk_calendar.png
    ├── 05_accuracy_analysis.png
    ├── 06_category_deep_dive.png
    ├── 06_ar_ap_detailed.png
    ├── 07_improved_mape_metrics.png
    ├── 08_executive_dashboard.png ⭐ EXECUTIVE VIEW
    └── 09_analysis_recommendations.png
```

---

## 🚀 **HOW TO USE**

### **For Competition Submission**

**Primary Deliverable:**
- `FORECAST_OUTPUT_FINAL.csv` - 26-week forecast with all required columns

**Supporting Documentation:**
- `EXECUTIVE_SUMMARY.md` - Executive overview
- `dashboard/08_executive_dashboard.png` - Master dashboard
- `business_recommendations.csv` - Actionable recommendations

### **For Stakeholders**

**Start Here:**
1. Read `EXECUTIVE_SUMMARY.md` for overview
2. View `dashboard/08_executive_dashboard.png` for visual summary
3. Review `business_recommendations.csv` for action items

**Deep Dive:**
- `ACCURACY_REPORT.md` - Model performance details
- `PROBLEM_STATEMENT.md` - Problem understanding
- `FORECAST_OUTPUT_REPORT.md` - Forecast details

### **For Technical Review**

**Reproducibility:**
1. Run `data_cleaning.py` (if needed)
2. Run `00_model_comparison.py` (model selection)
3. Run `04_forecast_option_c_production.py` (main forecast)
4. All outputs will be generated

**Validation:**
- `01_forecast_option_a.py` - Forward validation
- `02_forecast_option_b1.py` - Rolling validation
- `03_forecast_option_b2.py` - Monthly validation
- `05_accuracy_analysis.py` - Comprehensive accuracy

---

## 📊 **KEY METRICS SUMMARY**

| Metric | Value | Interpretation |
|--------|-------|----------------|
| **Direction Accuracy** | 60% | Better than random (50%) |
| **Average MAE** | $1.84M | Acceptable for cash flow |
| **Threshold MAPE** | 30.7% | Good when |actual| > $1M |
| **CI Coverage** | 86% | Well-calibrated |
| **1-Month Accuracy** | 75% direction, $1.36M MAE | Excellent |
| **6-Month Accuracy** | ~60% direction, ~$2.0-2.5M MAE | Acceptable |

---

## 💡 **TOP 3 RECOMMENDATIONS**

1. **Optimize AR Collection Timing** (High Priority, High Impact)
   - AR drives 85% of inflows. Improving collection speed could improve cash position by ~$2.4M/week

2. **Review Netting Operations Timing** (High Priority, High Impact)
   - Netting AP drives 52% of outflows. Optimizing timing improves predictability

3. **Implement Monthly Forecast Updates** (High Priority, Medium Impact)
   - Monthly updates maintain accuracy as new data arrives

---

## ✅ **PROJECT STATUS**

**Completion:** 100% ✅

- ✅ All 6 required deliverables complete
- ✅ Model validated with multiple approaches
- ✅ 6-month forecast generated
- ✅ Category analysis (AR/AP) complete
- ✅ Anomaly detection implemented
- ✅ Comprehensive dashboards created
- ✅ Business recommendations provided
- ✅ Documentation complete

**Ready for:** Competition Submission ✅

---

**Last Updated:** December 19, 2025  
**Project Team:** Datathon 2025  
**Contact:** See repository for all files and documentation

