11. Python - Data Analytics - Random Forest Model
Import libraries:
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
Create a model and fit it. Then use it to predict.
forest_model = RandomForestRegressor(random_state=1)
forest_model.fit(train_X, train_y)
melb_preds = forest_model.predict(val_X)
print(mean_absolute_error(val_y, melb_preds))
Comments
Post a Comment