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

Popular posts from this blog

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

20. Data Analytics - Analyze Data to Answer Questions - Week 1

3. Algorithms - Selection Sort