This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from starlette.applications import Starlette | |
| from starlette.responses import HTMLResponse, JSONResponse | |
| from starlette.staticfiles import StaticFiles | |
| from starlette.middleware.cors import CORSMiddleware | |
| import uvicorn, aiohttp, asyncio | |
| from io import BytesIO | |
| from fastai import * | |
| from fastai.vision import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = RandomForestRegressor(n_estimators=100, max_features='log2', n_jobs=-1) | |
| m.fit(X_train, y_train) | |
| print_score(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = RandomForestRegressor(max_features='sqrt', n_jobs=-1) | |
| m.fit(X_train, y_train) | |
| print_score(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = RandomForestRegressor(max_features='log2', n_jobs=-1) | |
| m.fit(X_train, y_train) | |
| print_score(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = RandomForestRegressor(n_jobs=-1) | |
| m.fit(X_train, y_train) | |
| print_score(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from sklearn import metrics | |
| preds = np.stack([t.predict(X_valid) for t in m.estimators_]) | |
| preds[:,0], np.mean(preds[:,0]) | |
| plt.plot([metrics.r2_score(y_valid, np.mean(preds[:i+1], axis=0)) for i in range(10)]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |