Skip to content

Instantly share code, notes, and snippets.

@mzaradzki
Created July 3, 2017 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzaradzki/4f274dd96186dff3dfbb7cf82b147ddc to your computer and use it in GitHub Desktop.
Save mzaradzki/4f274dd96186dff3dfbb7cf82b147ddc to your computer and use it in GitHub Desktop.
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