feat(backend): add formula-based LiDAR weight prediction baseline#46
Open
nicole-gomes wants to merge 2 commits into
Open
feat(backend): add formula-based LiDAR weight prediction baseline#46nicole-gomes wants to merge 2 commits into
nicole-gomes wants to merge 2 commits into
Conversation
| def predict( | ||
| self, | ||
| request: WeightEstimationRequest, | ||
| ) -> WeightEstimationResponse: ... |
| def predict( | ||
| self, | ||
| request: WeightEstimationRequest, | ||
| ) -> WeightEstimationResponse: ... |
Tcordeir0
approved these changes
Jun 11, 2026
Tcordeir0
left a comment
Collaborator
There was a problem hiding this comment.
CI verde ✅. Revisei: a fórmula heart-girth está correta e o pacote prediction/ ficou bem isolado e extensível pro modelo treinado futuro. Baseline backend-only, não mexe no app — alinhado. Só vamos manter o peso rotulado como baseline/preliminar e sem plugar no app até termos o modelo treinado (pós coleta de 22/06). Mandou bem, aprovado! 🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new isolated
backend/prediction/package for bovine weight estimation based on LiDAR-derived morphometric measurements. It introduces a deterministic formula-based baseline using heart girth and body length, plus measurement validation, conservative confidence scoring, structured diagnostics, and unit tests. The goal is to support the first real-measurements phase with a production-oriented baseline that does not depend on the legacy 2D/api/v1/scandemo flow, synthetic data, or a trained supervised model.Motivation
This solves the need for a first-pass weight estimation module for the LiDAR measurements workflow while real ground-truth animal weights are not yet available for model training and calibration. The implementation creates a clear separation between the new LiDAR-based baseline path and the older image-based demo path, and it keeps the architecture extensible for a future trained model once real farm data is collected.
Closes #
Type of change
feat— new user-visible featurefix— bug fixperf— performance improvementrefactor— code change without behaviour changedocs— documentation onlytest— tests onlybuild/ci— build system or CI changeschore— other maintenancesecurity— security-related changeScope of change
mobile/— Expo / React Nativebackend/— FastAPI service.github/— CI, templates, governanceHow was this tested?
expo lint,ruff)tsc --noEmit, mypy where applicable)Manual and automated validation performed:
python -m unittest tests.test_weight_estimation_agentpython -m unittest discover testsmodel_versionandestimation_methodrequires_ground_truth_validation = trueis_formula_based = trueis_trained_model = falseNotes:
ruffcould not be executed in the current environment because Ruff was not installed locally or in the backend virtual environment.Screenshots or recordings
N/A — backend-only change.
Checklist
CODEOWNERS.Notes for the reviewer
Business rules implemented in this PR:
model_versionis fixed asformula-baseline-v0.1.0.estimation_methodis fixed asheart_girth_body_length_formula.chest_girth_cmandbody_length_cm.withers_height_cm,thoracic_depth_cm, andrump_width_cmare currently used for validation, plausibility, and diagnostics rather than as primary calculation inputs.requires_ground_truth_validation = trueis_formula_based = trueis_trained_model = false0.70.Plausible bovine ranges currently applied:
body_length_cm: 80 to 260withers_height_cm: 80 to 210thoracic_depth_cm: 35 to 120rump_width_cm: 20 to 100chest_girth_cm: 90 to 320Consistency checks currently applied:
chest_girth_cm / body_length_cmoutside0.85to1.70withers_height_cm / thoracic_depth_cmoutside1.25to3.20rump_width_cm / chest_girth_cmoutside0.15to0.45thoracic_depth_cm >= withers_height_cmDeferred work / follow-up:
model_registry.pywhen a trained model becomes available.