[FAQ] : Homework 6 Q3 - my best n_estimators is 150, not 100: check DictVectorizer(sparse=...)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
- #529 của @github-actions — đã đóng, không merge
Đá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
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python, scikit-learn
- Lĩnh vực
- documentation
Hướng nghiên cứu
An open linked pull request (#529) is already addressing this FAQ, and the payload names no files. Check the repository’s existing FAQ format and compare the proposed change with the issue’s answer. Done means the FAQ follows the project’s conventions and clearly explains the sparse=True setting and its Q3 result.
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 6 Q3: I sweep n_estimators over [10, 50, 100, 150] and my lowest validation RMSE is at 150, not 100. My random_state is 1 and my split calls are exactly as written. What am I doing wrong?
Answer
Almost certainly nothing — check your DictVectorizer. The homework says:
Use
DictVectorizer(sparse=True)to turn the dataframes into matrices.
If you used the default sparse=False (which is what the 06-trees lecture notebook uses, so
it is a very easy thing to copy), you get different numbers. Both runs below are identical code,
same random_state=1, same splits — only the sparse argument differs:
sparse=True (csr_matrix)
n_estimators=10 1.837054
n_estimators=50 1.771567
n_estimators=100 1.768136 <-- lowest -> answer 100
n_estimators=150 1.768804
sparse=False (ndarray)
n_estimators=10 1.839221
n_estimators=50 1.772875
n_estimators=100 1.768158
n_estimators=150 1.767692 <-- lowest -> answer 150
The Q3 answer flips: 100 with sparse=True, 150 with sparse=False. Use sparse=True, since
that is what the homework specifies, and submit 100.
Why do the numbers differ at all? scikit-learn's tree builder takes a different code path for CSR
sparse matrices than for dense arrays. The algorithm is the same, but floating-point summation
order and tie-breaking in split search differ slightly, and those tiny differences change which
samples land in which leaf. The effect is small (~0.002 RMSE here) but it is larger than the 100-vs-150
margin, which is only 0.0007 — so it flips the ranking.
The margin is genuinely tight, which is why this question is worth double-checking:
dv = DictVectorizer(sparse=True) # <- required by the homework
X_train = dv.fit_transform(df_train.to_dict(orient='records'))
X_val = dv.transform(df_val.to_dict(orient='records'))
For reference, the other questions are not sensitive to this setting — Q1 (model_year), Q4
(10) and Q5 (vehicle_weight) come out the same either way. Q2 shifts from 1.837 to 1.839, which
still rounds to the 1.837 option. Only Q3 actually changes.
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
- 8
- Fork
- 20
- Merge trung bình
- 4 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DataTalksClub/faq
-
Two different inputs get the same XGBoost churn probability in my Flask API—does that mean my model is broken?Có thể đã có người làm @github-actions đã nhận 1 ngày trước. Đang mởfaq-proposal
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
DataTalksClub/faq#571 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[FAQ] How do I use `GridSearchCV` with parallel processing, and how do I fix the scikit-learn parallel-processing warning?Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởfaq-proposal
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
DataTalksClub/faq#551 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
DataTalksClub/faq#550 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Fixing ValueError: This solver needs samples of at least 2 classes in Logistic RegressionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởfaq-proposal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
DataTalksClub/faq#532 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[FAQ] Commit ID for ProjectsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởfaq-proposal
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
DataTalksClub/faq#503 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của DataTalksClub/faq
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
btclib-org/btclib#3062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Run evals automatically in CIĐang mởarea:evals area:infra enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jse-avl/support-bot#4 · 1 bình luận ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
qte77/agentic-job-offer-to-application-kit#487 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
On a free-threaded build, `_decrypted` can report a ledger locked mid-sign as a damaged fileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
btclib-org/btclib-wallet#801 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 94/100