Skip to content

Instantly share code, notes, and snippets.

@stasSajin
Last active July 27, 2020 02:55
Show Gist options
  • Save stasSajin/63ee07ea18574e62244ea7be9c2084b0 to your computer and use it in GitHub Desktop.
Save stasSajin/63ee07ea18574e62244ea7be9c2084b0 to your computer and use it in GitHub Desktop.
def estimate_rf(df):
X = df.income.values.reshape(-1,1)
y = df.minutes.values
rf_reg = RandomForestRegressor(100, n_jobs=8, oob_score=True)
rf_reg.fit(X,y)
# store residuals
y_new = df.minutes - reg.oob_prediction_
return y_new[df[group == 1]].mean() - y_new[df[group == 0]].mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment