Logo Lanfrica

mayas-spec/commodity-segregation

Domain:

agriculturesocioeconomic

Record type:

datasetsoftware
Creator:
may
Host:
K-Means market segmentation of Ghana commodity prices across 76 markets and 14 regions — built with MySQL, Python (scikit-learn), and Streamlit. # Ghana Commodity Market Segmentation A data science project that segments Ghana's food commodity markets into distinct tiers using K-Means clustering, built with MySQL, Python, and Streamlit. --- ## Overview This dashboard analyses **10,779 commodity price records** across **76 markets**, **76 commodities**, and **14 regions** in Ghana. Markets are clustered into tiers based on price behaviour and commodity mix, providing actionable intelligence for procurement, policy, and supply chain decisions. **Clustering features:** - Average price level - Price volatility (standard deviation) - Number of commodities tracked - Retail-to-wholesale price ratio - Price range (max − min) --- ## Dashboard | Tab | Description | |-----|-------------| | Overview | KPI metrics, average price by region, top commodities, region summary table | | Segmentation | K-Means cluster results, elbow curve, silhouette score, radar profiles, exportable table | | Market Explorer | Drill into any market — segment, price trends, commodity breakdown, peer markets | | SQL Workbench | MySQL views used for feature engineering and a live query runner | --- ## Tech Stack | Layer | Tool | |-------|------| | Database | MySQL 8 | | Data processing | Python, pandas, scikit-learn | | Visualisation | Plotly | | Dashboard | Streamlit | | DB connector | PyMySQL | --- ## Project Structure ``` . ├── data/ │ └── Commodity prices _04.11.25.csv # Raw dataset ├── db_setup.py # Loads CSV into MySQL, creates views ├── app.py # Streamlit dashboard ├── .env # MySQL credentials (not committed) └── .gitignore ``` --- ## Setup ### 1. Clone the repository ```bash git clone cd grp1 ``` ### 2. Install dependencies ```bash pip install streamlit pymysql pandas numpy scikit-learn plotly python-dotenv ``` ### 3. Configure environment Create a `.env` file in the project root: ```env MYSQL_HOST=localhost MYSQL_PORT=3306 …