Skip to content

Instantly share code, notes, and snippets.

@prratek
Last active September 23, 2018 00:18
Show Gist options
  • Save prratek/0a41376535f0909556dadf030b74f86c to your computer and use it in GitHub Desktop.
Save prratek/0a41376535f0909556dadf030b74f86c to your computer and use it in GitHub Desktop.
Code for Random Forest Medium blog post
import pandas as pd
from sklearn.ensemble import RandomForestRegressor
n = 100 # use every 100th row
df = pd.read_csv('{PATH_TO_DATA}train.csv', skiprows=lambda i: i % n != 0)
m = RandomForestRegressor() # instantiate the RandomForestRegressor objects
m.fit(X_train, y_train) # train the model
m.score(X_valid, y_valid) # score it on your validation set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment