Skip to content

Instantly share code, notes, and snippets.

@rajshah4
Last active May 21, 2021 18:18
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 rajshah4/497ee3fb99ff27db22d35e70f39146a0 to your computer and use it in GitHub Desktop.
Save rajshah4/497ee3fb99ff27db22d35e70f39146a0 to your computer and use it in GitHub Desktop.
BostonModel
import pandas as pd
from sklearn.ensemble import RandomForestRegressor
import pickle
import datetime
## load data
df = pd.read_csv('/content/odsc-ml-drum/data/boston_housing.csv')
df.head()
## set features and target
X = df.drop('MEDV', axis=1)
y = df['MEDV']
## train the model
rf = RandomForestRegressor(n_estimators = 20)
rf.fit(X,y)
## serialize the model
with open('/content/odsc-ml-drum/src/custom_model/rf.pkl', 'wb') as pkl:
pickle.dump(rf, pkl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment