Financial Health Prediction modelling for African MSMEs
# MSME Financial Health Index (FHI) Prediction
This project aims to predict the Financial Health Index (FHI) of small and medium-sized enterprises (SMEs) across Southern Africa (Eswatini, Lesotho, Malawi, and Zimbabwe). The model uses features such as business characteristics, owner demographics, financial behavior, and risk factors.
## Prerequisites
- **Python 3.10+**
- **Mac Users (Apple Silicon)**: Ensure `libomp` is installed for XGBoost.
```bash
brew install libomp
```
## Setup Instructions
1. **Create and Activate Virtual Environment**:
```bash
python3 -m venv venv
source venv/bin/activate
```
2. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
## Usage
### 1. Model Training
To train the model, perform hyperparameter tuning, and evaluate performance using 5-fold Stratified Cross-Validation:
```bash
python3 train.py
```
This script will:
- Preprocess the data (handling missing values, feature engineering).
- Run a Randomized Search for optimal XGBoost hyperparameters.
- Save the final model to `model.pkl` and encoders to `encoders.pkl`.
### 2. Generate Predictions
To generate predictions for the test set:
```bash
python3 predict.py
```
This will create a `submission.csv` file in the project root.
### 3. Data Analysis
To view feature importance and target distribution analysis:
```bash
python3 analyze_imp.py
```
## Project Structure
- `preprocess.py`: Contains data cleaning and feature engineering logic.
- `train.py`: Training pipeline with hyperparameter tuning.
- `predict.py`: Inference script for generating test set predictions.
- `analyze_imp.py`: Utility for analyzing model performance and feature importancia.
- `data/`: Contains raw CSV data files (`Train.csv`, `Test.csv`, etc.).