Skip to content

AGG-131: score feature rows with HH/CG LightGBM boosters - #13

Merged
anthrax63 merged 2 commits into
mainfrom
feat/agg-131-lightgbm-scoring
Aug 4, 2026
Merged

AGG-131: score feature rows with HH/CG LightGBM boosters#13
anthrax63 merged 2 commits into
mainfrom
feat/agg-131-lightgbm-scoring

Conversation

@anthrax63

Copy link
Copy Markdown
Member

Summary

  • Load two LightGBM boosters (hh_beeline_bezzalog_2026_05_04_model, cg_beeline_bezzalog_2026_05_04_model) once at process start from KZ_SCORING_HH_MODEL_PATH / KZ_SCORING_CG_MODEL_PATH.
  • Enrich every row returned by /single and /multi with HH_score and CG_score — raw booster.predict() output in [0, 1] (per the note in AGG-131 that keeps new_model_pd semantics).
  • Row values are projected onto booster.feature_name() in order; missing keys become NaN so LightGBM handles them as native missing values.
  • Both paths are optional — empty path disables the corresponding model, response schema is otherwise unchanged (fully backward-compatible).
  • Helm chart gets an optional models.volume that mounts any k8s volume source (PVC / ConfigMap / Secret / …) at a configurable mountPath, so ops can update model files without rebuilding the image.

Closes AGG-131. Depends on AGG-128 (PR #35 in aggregion/kz-scoring) for the full feature-set that the boosters read.

Test plan

  • pytest -q (50 passed) — new coverage in tests/test_scoring.py (unit-level: _to_float, BoosterScorer, ScoringService, real-LightGBM round-trip), tests/test_lookup.py (integration through LookupService), tests/test_endpoints.py (/single / /multi endpoint-level scoring).
  • ruff check . — clean.
  • helm lint chart — clean.
  • helm template chart --set models.volume.enabled=true --set models.volume.persistentVolumeClaim.claimName=… — mounts and env wire up.
  • Coordinate with Абай on the score format: currently returning raw PD, matching the new_model_pd column in Описание переменных модели.xlsx. If he expects a 0..1000 score, a scalar transform on top is a one-line follow-up.
  • Validate on the 3 golden IIN once AGG-128 is merged and the feature matrix contains the full column set.

🤖 Generated with Claude Code

DevOps (Aivo agent) and others added 2 commits August 4, 2026 14:13
Load two boosters (hh_beeline_bezzalog_2026_05_04_model,
cg_beeline_bezzalog_2026_05_04_model) once at startup from
KZ_SCORING_HH_MODEL_PATH / KZ_SCORING_CG_MODEL_PATH and enrich each
row returned by /single and /multi with HH_score and CG_score.

Feature vectors are projected onto booster.feature_name() in order;
missing keys are passed to LightGBM as NaN so tree splits treat them
as native missing values. Predictions are returned as raw PD (0..1)
per AGG-131. Leaving a path empty disables that model — the response
schema is unchanged, so the enrichment is fully backward-compatible.

The chart gets an optional models.volume that mounts any k8s volume
source (PVC, ConfigMap, Secret, ...) at a configurable mountPath, so
operators can update the model files without rebuilding the image.

Closes AGG-131.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Resolve conflicts introduced by main-branch changes (SALT_PKB hex-decode,
X-API-Key auth gate, pipeline secrets context key):

- config.py: keep both hh_model_path/cg_model_path (feature) and api_token
  (main) fields.
- lookup.py: apply scoring first, then _shape() the result — scoring
  mutates rows in place, so both the list (iin-only) and single-dict
  (iin+phone) shapes carry HH_score/CG_score.
- tests/conftest.py: keep env-setdefault + noqa: E402 layout from main,
  add BoosterScorer/ScoringService import.
- tests/test_endpoints.py, tests/test_lookup.py: switch scoring tests from
  fake_secrets.value (hex-encoded) to fake_secrets.salt_bytes (raw), so
  the row_id derived on the test side matches what LookupService derives
  after hex-decoding.

87/87 tests pass.

Co-authored-by: multica-agent <github@multica.ai>
@anthrax63
anthrax63 merged commit 9c744ec into main Aug 4, 2026
3 checks passed
@anthrax63
anthrax63 deleted the feat/agg-131-lightgbm-scoring branch August 4, 2026 14:51
@anthrax63 anthrax63 mentioned this pull request Aug 4, 2026
3 tasks
anthrax63 added a commit that referenced this pull request Aug 4, 2026
The 0.4.1 tag was reused twice (PR #13 boosters, PR #14 chart extras)
after v0.4.1 shipped, making Argo unable to detect a rollable image.
Bump the tag chain (pyproject, __init__, Chart appVersion) to 0.5.0 so
GHA publishes a fresh `v0.5.0` image and the kartel-deploy overlay can
pin to it.

Co-authored-by: DevOps (Aivo agent) <devops@aivoagent.bot>
Co-authored-by: multica-agent <github@multica.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant