Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#515 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
35/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, numpy, python, scikit-learn

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
7
Forks
20
Merge medio
7 d 9 h
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DataTalksClub/faq

Todos los issues de DataTalksClub/faq

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.