Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#515 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, numpy, python, scikit-learn

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
7
フォーク
20
平均マージ
7日 9時間
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DataTalksClub/faq のほかの issue

DataTalksClub/faq の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。