A comprehensive machine learning system for predicting land values and crop yields in Kenya, with a user-friendly web interface and RESTful API.
- Land Value Prediction: Accurate valuation of land based on location, size, soil type, and amenities
- Crop Yield Estimation: Predict potential yields for various crops based on environmental factors
- Web Interface: Intuitive UI for easy interaction with the prediction models
- RESTful API: Full-featured API for programmatic access to predictions
- Feedback System: Collects user feedback to continuously improve model accuracy
- Scalable Architecture: Ready for deployment to cloud platforms
landvalue/
├── api/ # API service code and templates
│ ├── static/ # Static files (CSS, JS, images)
│ └── templates/ # HTML templates
├── data/ # Data storage
│ ├── raw/ # Raw datasets
│ ├── processed/ # Processed data
│ └── feedback/ # User feedback data
├── models/ # Trained models
│ └── best/ # Best performing models
├── notebooks/ # Jupyter notebooks for exploration
├── src/ # Source code
│ ├── data/ # Data collection and processing
│ ├── features/ # Feature engineering
│ ├── models/ # Model training and evaluation
│ └── utils/ # Utility functions
├── tests/ # Test files
├── .env.example # Example environment variables
├── deploy.py # Deployment script
├── Procfile # Heroku procfile
├── requirements.txt # Python dependencies
└── run.py # Application entry point
- Python 3.9+
- pip (Python package manager)
- Git
-
Clone the repository
git clone https://github.com/yourusername/kenya-land-valuation.git cd kenya-land-valuation -
Set up a virtual environment
# Windows python -m venv venv .\venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env with your API keys and configuration -
Train the models
python train_land_value.py python train_yield_model.py
-
Run the application
python run.py
Open your browser to http://localhost:5000
Endpoint: POST /api/predict/land-value
Request Body:
{
"county": "Nairobi",
"land_use_type": "residential",
"size_acres": 5.0,
"soil_type": "volcanic",
"elevation": 1800,
"rainfall": 1000,
"temperature": 25.5,
"has_electricity": true,
"has_water": true,
"has_road": true
}Response:
{
"prediction": 25000000,
"prediction_millions": 25.0,
"currency": "KES",
"unit": "per acre"
}Endpoint: POST /api/predict/yield
Request Body:
{
"county": "Nakuru",
"crop": "Maize",
"soil_type": "loam",
"elevation": 2000,
"rainfall": 1200,
"temperature": 22.0,
"area_ha": 2.5,
"irrigation": true,
"fertilizer_kg_per_ha": 150
}Response:
{
"prediction": 3.5,
"unit": "tonnes/ha",
"total_yield": 8.75,
"total_unit": "tonnes"
}- Install the Heroku CLI
- Log in to your Heroku account:
heroku login
- Deploy the application:
python deploy.py --provider heroku --app-name your-app-name
For AWS deployment, you can use the provided Dockerfile with ECS or Elastic Beanstalk:
# Build the Docker image
docker build -t kenya-land-valuation .
# Run locally for testing
docker run -p 5000:5000 kenya-land-valuation- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Kenya National Bureau of Statistics (KNBS) for open data
- FAO for agricultural datasets
- OpenStreetMap for geographic data