Skip to content

Homework 4 (2026) Q5 std mismatch — 0.013 instead of 0.007 (solver must be liblinear) #482

Closed as not planned

Description

@marcos-Nieves-24

Course

machine-learning-zoomcamp

Question

Why does my Homework 4 (2026) Q5 cross-validation std not match any option — I get 0.013 instead of 0.007?

Answer

Fix first — copy the model constructor exactly as the homework specifies:

KFold(n_splits=5,shuffle=True, random_state=1)
# per fold, with a fresh DictVectorizer fit on the train fold only:
model = LogisticRegression(solver='liblinear', C=1.0, max_iter=1000)

The bare constructor LogisticRegression(max_iter=1000) silently uses the default solver lbfgs. On the 2026 lead-scoring data it throws ConvergenceWarning: lbfgs failed to converge and produces fold AUCs ~[0.776, 0.787, 0.799, 0.811, 0.780] with std 0.013 — a different multiple-choice option. With solver='liblinear' the folds are ~[0.731, 0.730, 0.736, 0.741, 0.721] with std 0.007, the correct answer. Same data, same seed, wrong solver, wrong answer.

Why this happens:

lbfgs and liblinear optimize differently on unscaled one-hot features, so they converge to different weights and therefore different per-fold AUCs. The warning in your output is the tell: if you see ConvergenceWarning in Q5, your solver is wrong. Related trap in the same notebook: Q1 must exclude converted itself from the single-variable AUC loop (it scores 1.000 against itself and answers nothing).

Canonical homework (pinned 2026 release):

https://github.com/DataTalksClub/machine-learning-zoomcamp/blob/main/cohorts/2026/homework/04-evaluation/homework.md

Related lesson: 04-evaluation/07-cross-validation (mean = performance, std = stability across folds).

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

Activity

  1. marcos-Nieves-24 commented on Oct 19, 2026

    @marcos-Nieves-24
    Author

    Superseded by PR #483 with the entry in the repo's _questions format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions