Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.32 KB

File metadata and controls

36 lines (28 loc) · 1.32 KB

HarvestNimbus – AI/ML Engineer 2 Starter (Crop Recommender + Weather)

This starter matches your 4-week plan and gives you a working FastAPI backend + ML training scaffold.

Quickstart

# 1) Create env & install deps
python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# 2) (Optional) Put your CSV into ./data/crop_data.csv and edit training/train.py feature names

# 3) Train model (writes ./model artifacts)
python training/train.py

# 4) Run API (uses ./model artifacts + OpenWeatherMap)
uvicorn app.main:app --host 0.0.0.0 --port 8000

# 5) Test
curl -X POST http://localhost:8000/recommend -H "Content-Type: application/json" -d @sample_request.json

Environment

Copy .env.example to .env and set your OpenWeatherMap key:

OPENWEATHER_API_KEY=your_key_here

Files

  • training/train.py – edit feature names to fit your dataset, trains an XGBoost Classifier, saves model and encoders.
  • app/main.py – FastAPI app exposing /health, /recommend, /weather, /climate-alerts.
  • app/utils.py – weather fetching + caching with TTL.
  • app/config.py – env + settings.
  • requirements.txt – dependencies.
  • sample_request.json – example request body.
  • Dockerfile, Procfile – deployment helpers (Render/Heroku compatible).