[FAQ] Homework 6 Q4: How do I calculate mean RMSE when selecting max_depth?

オープン 初心者向け
#545 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

FAQの回答はissue本文にすでに下書きされているので、作業は元のリンク先、cohorts/2026/homework/06-trees/homework.md の Homework 6 Question 4 と照らし合わせて確認することです。pandas のgroupbyスニペットを実行し、例示用の平均値2.2と2.3が正しいか確かめてください。回答が正確と確認されるか修正され、FAQの項目を追加できる状態になれば完了です。

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

説明

Course

machine-learning-zoomcamp

Question

How do I calculate mean RMSE when selecting max_depth in Homework 6 Q4? Should
I choose the best individual forest, average predictions, or average the RMSE
scores for each depth?

Answer

Average the four validation RMSE scores for each fixed depth, then select
the depth with the lowest mean. Keep the individual RMSE values at full
precision until after calculating the mean.

In the 2026 assignment, each max_depth in [10, 15, 20, 25] is evaluated with
n_estimators in [10, 50, 100, 150], with random_state=1. This produces
16 models, four validation RMSE values per depth, and four depth-level means.
Use the same prepared training and validation data for every model.

For a fixed depth d, the comparison score is:

mean_rmse(d) = (rmse(d, 10) + rmse(d, 50) + rmse(d, 100) + rmse(d, 150)) / 4

Here is a small, runnable example using hypothetical scores and a smaller
grid
, not the homework results:

import pandas as pd

scores = pd.DataFrame([
    {"max_depth": 2, "n_estimators": 5, "val_rmse": 2.1},
    {"max_depth": 2, "n_estimators": 15, "val_rmse": 2.3},
    {"max_depth": 3, "n_estimators": 5, "val_rmse": 1.8},
    {"max_depth": 3, "n_estimators": 15, "val_rmse": 2.8},
])

mean_rmse = scores.groupby("max_depth")["val_rmse"].mean()
print(mean_rmse.round(6))  # Round only for display.

The illustrative means are 2.2 for depth 2 and 2.3 for depth 3. Although depth 3
contains the best individual model (RMSE 1.8), depth 2 has the lower mean.

Do not replace this calculation with:

  • The minimum RMSE for each depth, or the best single depth/size combination.
  • The mean of the predictions from several forests; that evaluates a different
    ensemble model.
  • The square root of the mean of the four MSE values; the square root is
    nonlinear, so this generally differs from the arithmetic mean of four RMSEs.

If depth-level means tie, report the tie and follow any explicit assignment or
maintainer guidance. The example above intentionally has a unique minimum.

Source: 2026 Homework 6, Question 4.

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
スター
8
フォーク
20
平均マージ
3日 14時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

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

DataTalksClub/faq のほかの issue

DataTalksClub/faq の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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