Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[FAQ] HW5 (2026): predict_proba differs — locked env, artifact checksum, normalize_record

Aperta
#515 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
35/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, numpy, python, scikit-learn

Direzione di ricerca

The issue already provides a full FAQ answer, including commands and references to cohorts/2026/homework/05-deployment/homework.md and model.py. Check whether that guidance matches the frozen homework release and API behavior; done means the answer is accurate and resolves the reported probability mismatch. The FAQ checklist says the answer is already complete, so this is not an evident first contribution.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Course

machine-learning-zoomcamp

Question

Homework 5 (2026): Why do my predict_proba results differ from the expected options, even though my code runs without errors?

Answer

Fix first — make sure you run the frozen 2026 release exactly as checked in, without retraining or regenerating anything:

  1. Verify the artifact before using it (from cohorts/2026/homework/05-deployment/):

    sha256sum pipeline.bin
    

    It must match the hash in homework.md. If it differs, re-download the directory instead of debugging numbers.

  2. Use the locked environment, don't regenerate it:

    uv sync --locked
    

    Do not run uv sync without --locked and do not regenerate uv.lock. A different scikit-learn/numpy build can shift probabilities.

  3. Normalize the lead exactly like the API does (model.py):

    import pickle
    from model import normalize_record
    
    with open("pipeline.bin", "rb") as f:
        pipeline = pickle.load(f)
    
    record = normalize_record(lead)  # training-set medians, "NA" for missing categoricals
    prob = float(pipeline.predict_proba([record])[0, 1])
    

    Hand-rolling imputation (e.g. fillna(0)) instead of normalize_record changes the vector and the probability.

  4. Serve and containerize without edits:

    uv run uvicorn predict:app --host 0.0.0.0 --port 9696
    docker build -t zoomcamp-model:2026-hw5 .
    docker run --rm -p 9696:9696 zoomcamp-model:2026-hw5
    curl -s http://localhost:9696/health
    

    Free port 9696 first (stop any local uvicorn). The container must return the same inference as local; if it doesn't, the artifact or lockfile inside the build context differs.

Reference: cohorts/2026/homework/05-deployment/homework.md (frozen lead-scoring release, DictVectorizer + LogisticRegression(solver="liblinear", C=1.0)).

Checklist

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links
Lingua principale
Python
Stelle
7
Fork
20
Merge medio
7g 9h
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DataTalksClub/faq

Tutte le issue di DataTalksClub/faq

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.