Analysing food security in kenya
# 🏡 Food Security Analysis in Kenya
This project provides a Streamlit web application for analyzing food security in Kenyan households using a provided dataset. It covers data loading, preprocessing, statistical analysis, and predictive modeling for the Household Food Insecurity Access Scale (HFIAS).
## 🚀 Features
* **Data Loading:** Upload SPSS (.sav) files for analysis.
* **Data Preprocessing:**
* Handling of missing values using mode imputation.
* Conversion of specific string codes (e.g., '888') to missing values (`NaN`).
* Outlier detection (using IQR method).
* One-Hot Encoding for categorical features.
* **Statistical Analysis:**
* Correlation analysis and visualization (heatmap).
* **Predictive Modeling:**
* Random Forest Regressor to predict Household Food Insecurity Access Scale (HFIAS).
* Model evaluation metrics (R-squared, MAE, RMSE, MAPE, Percentage Accuracy).
* Feature importance analysis.
## 📦 Installation
1. **Clone the repository (or download the `app.py` file):**
```bash
git clone # Replace with your repository URL if hosted
cd food-security-app # Or wherever your app.py is located
```
2. **Create a virtual environment (recommended):**
```bash
python3 -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
```
3. **Install the required packages:**
```bash
pip install streamlit pandas numpy matplotlib seaborn scikit-learn pyreadstat scipy
```
*(Note: You might need to install `ipykernel` if you encounter issues related to Jupyter notebooks, though it's not strictly necessary for the Streamlit app itself.)*
## 🏃♀️ How to Run
1. **Navigate to the project directory** in your terminal where `app.py` is located.
2. **Ensure your virtual environment is activated** (if you created one).
3. **Run the Streamlit application:**
```bash
streamlit run app.py
```
4. Your browser will automatically open to the Streamlit app (usually at `
localhost`).
## 📁 Data
The application expects an SPSS (`.sav`) file as inp …