Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from sklearn.ensemble import RandomForestClassifier
dfRFC = dfOHE.sample(frac=1) # shuffle the dataset before spliting it in 2 parts
dfRFC_trn = dfRFC[0:45000] # training set
dfRFC_tst = dfRFC[45000:] # testing set
RFC = RandomForestClassifier(n_estimators=20, # number of trees in the "forest" ensemble
max_depth=25) # maximum depth of each tree
RFC.fit(dfRFC_trn[predictors].values, dfRFC_trn['status_group_enc'].values)
# model accuracy score between 0% and 100%
score = RFC.score(dfRFC_tst[predictors].values, dfRFC_tst['status_group_enc'].values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment