[{"data":1,"prerenderedAt":122},["ShallowReactive",2],{"term-t\u002Ftrain-test-split":3,"related-t\u002Ftrain-test-split":108},{"id":4,"title":5,"acronym":6,"body":7,"category":90,"description":91,"difficulty":92,"extension":93,"letter":94,"meta":95,"navigation":53,"path":96,"related":97,"seo":102,"sitemap":103,"stem":106,"subcategory":6,"__hash__":107},"terms\u002Fterms\u002Ft\u002Ftrain-test-split.md","Train-Test Split",null,{"type":8,"value":9,"toc":84},"minimark",[10,15,19,23,26,30,73,77,80],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"A train-test split is holding back a chunk of your data that the model never gets to see while learning, specifically so you have something honest to grade it on afterward. Training a model and then testing it on the same data it already memorized is like grading a student on the exact quiz they used to study, of course they'll ace it.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A train-test split divides a dataset into a portion used to fit the model, the training set, and a portion held out entirely until evaluation, the test set, so performance metrics reflect how the model generalizes to unseen data rather than how well it memorized the training data. A three-way split adds a validation set, used for tuning hyperparameters, so the test set stays untouched until the very end.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","from sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(\n    X, y, test_size=0.2, random_state=42\n)\n","python","",[38,39,40,48,55,61,67],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"from sklearn.model_selection import train_test_split\n",[41,49,51],{"class":43,"line":50},2,[41,52,54],{"emptyLinePlaceholder":53},true,"\n",[41,56,58],{"class":43,"line":57},3,[41,59,60],{},"X_train, X_test, y_train, y_test = train_test_split(\n",[41,62,64],{"class":43,"line":63},4,[41,65,66],{},"    X, y, test_size=0.2, random_state=42\n",[41,68,70],{"class":43,"line":69},5,[41,71,72],{},")\n",[11,74,76],{"id":75},"when-youll-hear-this","When You'll Hear This",[16,78,79],{},"\"You evaluated on the training data? That number means nothing, do a proper train-test split.\" \u002F \"We use an 80\u002F20 train-test split, plus a separate validation set for tuning.\"",[81,82,83],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":85},[86,87,88,89],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":75,"depth":50,"text":76},"ai","A train-test split is holding back a chunk of your data that the model never gets to see while learning, specifically so you have something honest to grade...","beginner","md","t",{},"\u002Fterms\u002Ft\u002Ftrain-test-split",[98,99,100,101],"Cross-Validation","Data Leakage","Overfitting","scikit-learn",{"title":5,"description":91},{"changefreq":104,"priority":105},"weekly",0.7,"terms\u002Ft\u002Ftrain-test-split","kno-GZjcbJmeHVTxorGzTGOUj88UQRbKvLarh4VNhgE",[109,113,116,119],{"title":98,"path":110,"acronym":6,"category":90,"difficulty":111,"description":112},"\u002Fterms\u002Fc\u002Fcross-validation","intermediate","Cross-validation is refusing to trust a model that only ever took one practice exam.",{"title":99,"path":114,"acronym":6,"category":90,"difficulty":111,"description":115},"\u002Fterms\u002Fd\u002Fdata-leakage","Data leakage is when your model accidentally gets to peek at the answer key before the test.",{"title":100,"path":117,"acronym":6,"category":90,"difficulty":111,"description":118},"\u002Fterms\u002Fo\u002Foverfitting","Overfitting is when your model gets TOO good at the training data and becomes useless on new data.",{"title":101,"path":120,"acronym":6,"category":90,"difficulty":92,"description":121},"\u002Fterms\u002Fs\u002Fscikit-learn","scikit-learn is the toolbox that made classical machine learning boringly easy in Python: it gives you dozens of ready-to-use algorithms, from linear regre...",1792528132148]