[{"data":1,"prerenderedAt":127},["ShallowReactive",2],{"term-r\u002Frandom-forest":3,"related-r\u002Frandom-forest":109},{"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":103,"sitemap":104,"stem":107,"subcategory":6,"__hash__":108},"terms\u002Fterms\u002Fr\u002Frandom-forest.md","Random Forest",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 random forest is what you get when you refuse to trust a single decision tree's opinion and instead grow hundreds of slightly different trees, each trained on a random slice of the data, and let them vote. Any one tree might be wrong in a weird way, but the crowd of trees averages out those individual quirks into a much more reliable answer.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A random forest is an ensemble method that trains many decision trees on random subsets of the data and features, then averages their predictions for regression or takes a majority vote for classification. Randomizing both the data samples and the features considered at each split decorrelates the individual trees, which reduces overfitting compared to a single decision tree while keeping much of its interpretability through feature importance scores.",[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.ensemble import RandomForestClassifier\n\nmodel = RandomForestClassifier(n_estimators=200, max_depth=10)\nmodel.fit(X_train, y_train)\nprint(model.feature_importances_)\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.ensemble import RandomForestClassifier\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],{},"model = RandomForestClassifier(n_estimators=200, max_depth=10)\n",[41,62,64],{"class":43,"line":63},4,[41,65,66],{},"model.fit(X_train, y_train)\n",[41,68,70],{"class":43,"line":69},5,[41,71,72],{},"print(model.feature_importances_)\n",[11,74,76],{"id":75},"when-youll-hear-this","When You'll Hear This",[16,78,79],{},"\"Random forest got us to 88% with almost no tuning, it's a great baseline before trying XGBoost.\" \u002F \"Check the feature importances from the random forest, that'll tell us what actually drives churn.\"",[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 random forest is what you get when you refuse to trust a single decision tree's opinion and instead grow hundreds of slightly different trees, each train...","intermediate","md","r",{},"\u002Fterms\u002Fr\u002Frandom-forest",[98,99,100,101,102],"Decision Tree","Gradient Boosting","XGBoost","Feature Engineering","Overfitting",{"title":5,"description":91},{"changefreq":105,"priority":106},"weekly",0.7,"terms\u002Fr\u002Frandom-forest","ac5HV0cQt4dW0BzmdYE1DGOn31GnIJWaNNeSGnn7lUs",[110,114,117,121,124],{"title":98,"path":111,"acronym":6,"category":90,"difficulty":112,"description":113},"\u002Fterms\u002Fd\u002Fdecision-tree","beginner","A decision tree is a model that learns to play twenty questions with your data. Is the income over $50k? Yes. Is the age over 30? No.",{"title":101,"path":115,"acronym":6,"category":90,"difficulty":92,"description":116},"\u002Fterms\u002Ff\u002Ffeature-engineering","Feature engineering is the unglamorous, hugely important work of turning raw, messy real-world data into the specific columns a model can actually learn fr...",{"title":99,"path":118,"acronym":6,"category":90,"difficulty":119,"description":120},"\u002Fterms\u002Fg\u002Fgradient-boosting","advanced","Gradient boosting builds a model the way you'd improve a rough first draft: you write it, look specifically at what it got wrong, then write a second pass...",{"title":102,"path":122,"acronym":6,"category":90,"difficulty":92,"description":123},"\u002Fterms\u002Fo\u002Foverfitting","Overfitting is when your model gets TOO good at the training data and becomes useless on new data.",{"title":100,"path":125,"acronym":6,"category":90,"difficulty":119,"description":126},"\u002Fterms\u002Fx\u002Fxgboost","XGBoost is the specific, ruthlessly optimized software library that turned gradient boosting from a solid idea into the thing that wins Kaggle competitions...",1792528114647]