[{"data":1,"prerenderedAt":126},["ShallowReactive",2],{"term-c\u002Fcross-validation":3,"related-c\u002Fcross-validation":109},{"id":4,"title":5,"acronym":6,"body":7,"category":90,"description":91,"difficulty":92,"extension":93,"letter":94,"meta":95,"navigation":59,"path":96,"related":97,"seo":103,"sitemap":104,"stem":107,"subcategory":6,"__hash__":108},"terms\u002Fterms\u002Fc\u002Fcross-validation.md","Cross-Validation",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",{},"Cross-validation is refusing to trust a model that only ever took one practice exam. You split your data into several chunks, train on most of them and test on the leftover chunk, then rotate which chunk gets left out and repeat, so every bit of data gets a turn being the surprise quiz. If your model does well across every rotation, you can actually trust the score instead of getting lucky with one easy test.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Cross-validation is a model evaluation technique that partitions data into k folds, trains on k-1 folds and evaluates on the remaining fold, then repeats this k times so every data point is used for both training and testing exactly once. It gives a more reliable estimate of how a model will perform on unseen data than a single train\u002Ftest split, and helps surface overfitting that a lucky split might hide.",[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 cross_val_score\nfrom sklearn.ensemble import RandomForestClassifier\n\nscores = cross_val_score(RandomForestClassifier(), X, y, cv=5)\nprint(scores.mean(), scores.std())  # average accuracy across 5 folds\n","python","",[38,39,40,48,54,61,67],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"from sklearn.model_selection import cross_val_score\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"from sklearn.ensemble import RandomForestClassifier\n",[41,55,57],{"class":43,"line":56},3,[41,58,60],{"emptyLinePlaceholder":59},true,"\n",[41,62,64],{"class":43,"line":63},4,[41,65,66],{},"scores = cross_val_score(RandomForestClassifier(), X, y, cv=5)\n",[41,68,70],{"class":43,"line":69},5,[41,71,72],{},"print(scores.mean(), scores.std())  # average accuracy across 5 folds\n",[11,74,76],{"id":75},"when-youll-hear-this","When You'll Hear This",[16,78,79],{},"\"Don't trust a single train\u002Ftest split, run 5-fold cross-validation before you claim 94% accuracy.\" \u002F \"Cross-validation showed the model's performance swings wildly between folds, something's off with the data.\"",[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","Cross-validation is refusing to trust a model that only ever took one practice exam.","intermediate","md","c",{},"\u002Fterms\u002Fc\u002Fcross-validation",[98,99,100,101,102],"Train-Test Split","Overfitting","F1 Score","scikit-learn","Model",{"title":5,"description":91},{"changefreq":105,"priority":106},"weekly",0.7,"terms\u002Fc\u002Fcross-validation","_4sgLhPzDQufl0YIAd64cWIskpLQjecrVC_6ldfn95k",[110,113,117,120,123],{"title":100,"path":111,"acronym":6,"category":90,"difficulty":92,"description":112},"\u002Fterms\u002Ff\u002Ff1-score","The F1 Score is the balanced average of precision and recall — a single number that captures both.",{"title":102,"path":114,"acronym":6,"category":90,"difficulty":115,"description":116},"\u002Fterms\u002Fm\u002Fmodel","beginner","A model is the trained AI — the finished product.",{"title":99,"path":118,"acronym":6,"category":90,"difficulty":92,"description":119},"\u002Fterms\u002Fo\u002Foverfitting","Overfitting is when your model gets TOO good at the training data and becomes useless on new data.",{"title":101,"path":121,"acronym":6,"category":90,"difficulty":115,"description":122},"\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...",{"title":98,"path":124,"acronym":6,"category":90,"difficulty":115,"description":125},"\u002Fterms\u002Ft\u002Ftrain-test-split","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...",1792528075536]