How syedmuhammadhunain/climate-machine-learning works
This project predicts crop yields and ranks 13 crops for drought scenarios in Punjab, Sindh, and Balochistan. The main workflow is climate inputs → validation and feature completion → model inference → comparison with typical provincial yields → ranked recommendations and caveats. A shared Python package also supports model training, evaluation, and presentation logic. FastAPI serves API and web pages; separate Streamlit and Hugging Face apps are documented. Frontend source files and model artifacts are not in the supplied tree, so their internal wiring is not shown.
Main entry points: model_service.py Model service · endpoints.py Prediction API routes · inference.py Yield inference · main.py App server and pages
Components 19
Data and model
- Feature engineering
src/climate_machine_learning/features.py - Training and evaluation
src/climate_machine_learning/training.py - Climate and yield data
- Saved model and metrics
Shared prediction runtime
- Yield inference
src/climate_machine_learning/inference.py - Crop ranking
src/climate_machine_learning/inference.py - Shared presentation logic
src/climate_machine_learning/presentation.py - Ranked crop results
app/schemas/recommend.py
FastAPI service
- Climate scenario
app/schemas/predict.py - Request and response schemas
app/schemas/recommend.py - Prediction API routes
app/api/v1/endpoints.py - App server and pages
app/main.py - Model service
app/services/model_service.py - Validation errors
app/core/exceptions.py
Other app surfaces
- Web frontend
frontend/climate-resilient-frontend - Streamlit app
streamlit_app/app.py - Hugging Face app
hf_space/app.py
Other components
- Farmer or officer
- NASA POWER
Connections 25
- Farmer or officer → Climate scenario: enters scenario
README.md - Climate scenario → Prediction API routes: submits to
README.md - Prediction API routes → Model service: calls
app/api/v1/endpoints.py - Prediction API routes → Request and response schemas: validates with
app/api/v1/endpoints.py - App server and pages → Prediction API routes: registers routes
app/main.py - App server and pages → Model service: loads at startup
app/main.py - App server and pages → Validation errors: registers handlers
app/main.py - Model service → Saved model and metrics: loads artifacts
app/services/model_service.py - Model service → Feature engineering: uses features
app/services/model_service.py - Model service → Yield inference: uses inference
app/services/model_service.py - Model service → Crop ranking: builds ranking
app/services/model_service.py - Crop ranking → Ranked crop results: formats results
app/services/model_service.py - Feature engineering → Yield inference: prepares inputs
src/climate_machine_learning/inference.py - Climate and yield data → Feature engineering: supplies data
README.md - NASA POWER → Climate and yield data: provides soil data
README.md - Feature engineering → Training and evaluation: builds training features
src/climate_machine_learning/training.py - Training and evaluation → Saved model and metrics: writes model results
README.md - Saved model and metrics → Yield inference: provides trained model
README.md - Web frontend → Prediction API routes: calls API
README.md - App server and pages → Web frontend: serves pages
app/main.py - Streamlit app → Yield inference: uses shared core
streamlit_app/app.py - Streamlit app → Shared presentation logic: uses shared presentation
streamlit_app/app.py - Hugging Face app → Yield inference: uses shared core
hf_space/app.py - Hugging Face app → Shared presentation logic: uses shared presentation
hf_space/app.py - Ranked crop results → Farmer or officer: returns results
README.md