Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#515 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, numpy, python, scikit-learn

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
7
Fork
20
Merge trung bình
7 ngày 9 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DataTalksClub/faq

Tất cả issue của DataTalksClub/faq

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.