テストセットを分けておく理由
未知のデータで性能を推定する
「テストセットを分けておく理由」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
The Real Question
A model that memorizes your data looks brilliant on it. The real question is how it does on data it has never seen.
Hold Some Data Back
So you set aside part of your data and never train on it. This locked-away slice is your test set, kept for the very end.
Train Here, Judge There
The model learns only from the training set. You then judge it on the untouched test set to see how it truly generalizes. 🎯
Why Not Score on Training
Scoring on the same rows it learned from is like grading a test with the answer key open. That number flatters the model and overstates its skill.
Generalization Is the Goal
You do not care how well it fits old data. You care about generalization: making good predictions on tomorrow's fresh, unseen rows.
Meet Overfitting
When a model nails training data but flops on the test set, it is overfitting. It memorized noise instead of learning the real pattern.
A Common Split
A simple, popular choice is to train on about 80% of rows and test on the remaining 20%. More data to learn, enough left to judge fairly.
Touch It Only Once
The test set is sacred. If you keep peeking and tweaking until the score looks good, you have quietly leaked it into your decisions.
Where the Split Happens
In scikit-learn, one helper does the splitting for you. It shuffles and carves your data into train and test parts in a single call.
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)The Honest Number
The score on the test set is your honest estimate of real-world performance. Trust it more than any glowing training score.
More Than a Formality
Holding out data is not red tape. It is the one habit that stops you from shipping a model that only ever worked on paper.
Quick Check
Why do you keep a separate test set?
Recap
You split data, learn on the train part, and judge on a sacred test set. That untouched slice is your honest read on real-world skill. 🎯
よくある質問
「テストセットを分けておく理由」レッスンは無料ですか?
はい。「テストセットを分けておく理由」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。
「テストセットを分けておく理由」で何を学びますか?
未知のデータで性能を推定する ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Data Science Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「テストセットを分けておく理由」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このData Science Academyレッスンでコードを書いて実行できますか?
はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- テストセットを分けておく理由
- train_test_splitを正しく使う
- K分割交差検証
- データリークを未然に防ぐ