Skip to content

ericx00/Landvaluation

Repository files navigation

Kenya Land Valuation & Crop Yield Prediction System

A comprehensive machine learning system for predicting land values and crop yields in Kenya, with a user-friendly web interface and RESTful API.

🌟 Features

  • 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

🏗️ Project Structure

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

🚀 Quick Start

Prerequisites

  • Python 3.9+
  • pip (Python package manager)
  • Git

Local Development

  1. Clone the repository

    git clone https://github.com/yourusername/kenya-land-valuation.git
    cd kenya-land-valuation
  2. Set up a virtual environment

    # Windows
    python -m venv venv
    .\venv\Scripts\activate
    
    # macOS/Linux
    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp .env.example .env
    # Edit .env with your API keys and configuration
  5. Train the models

    python train_land_value.py
    python train_yield_model.py
  6. Run the application

    python run.py

    Open your browser to http://localhost:5000

🌐 API Documentation

Land Value Prediction

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"
}

Crop Yield Prediction

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"
}

☁️ Deployment

Heroku Deployment

  1. Install the Heroku CLI
  2. Log in to your Heroku account:
    heroku login
  3. Deploy the application:
    python deploy.py --provider heroku --app-name your-app-name

AWS Deployment

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

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Kenya National Bureau of Statistics (KNBS) for open data
  • FAO for agricultural datasets
  • OpenStreetMap for geographic data

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors