<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Random Forests
Introduction
Decision trees leave you with a difficult decision.
A deep tree with lots of leaves will overfit because each prediction is coming from historical data from only the few houses at its leaf.
But a shallow tree with few leaves will perform poorly because it fails to capture as many distinctions in the raw data.
Even today's most sophisticated modeling techniques face this tension between underfitting and overfitting.
But, many models have clever ideas that can lead to better performance.
We'll look at the random forest as an example.
The random forest uses many trees, and it makes a prediction by averaging the predictions of each component tree.
It generally has much better predictive accuracy than a single decision tree and it works well with the default parameters.
If you keep modeling, you can learn more models with even better performance, but many of those are sensitive to getting the right settings.
Step1:  A RandomForest is built in much the same way that a decision tree is
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
file_path = 'input/melbourne_data.csv'
mb_data = pd.read_csv(file_path)
mb_data = mb_data.dropna(axis=0)
y = mb_data.Price
mb_predictors = ['Rooms', 'Bathroom', 'Landsize', 'BuildingArea', 'YearBuilt', 'Lattitude', 'Longtitude']
X = mb_data[mb_predictors]
from sklearn.model_selection import train_test_split
train_X, val_X, train_y, val_y = train_test_split(X, y, random_state=0)
Explanation: Random Forests
Introduction
Decision trees leave you with a difficult decision.
A deep tree with lots of leaves will overfit because each prediction is coming from historical data from only the few houses at its leaf.
But a shallow tree with few leaves will perform poorly because it fails to capture as many distinctions in the raw data.
Even today's most sophisticated modeling techniques face this tension between underfitting and overfitting.
But, many models have clever ideas that can lead to better performance.
We'll look at the random forest as an example.
The random forest uses many trees, and it makes a prediction by averaging the predictions of each component tree.
It generally has much better predictive accuracy than a single decision tree and it works well with the default parameters.
If you keep modeling, you can learn more models with even better performance, but many of those are sensitive to getting the right settings.
End of explanation
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error as mae
forest_model = RandomForestRegressor()
forest_model.fit(train_X, train_y)
melbourne_predictions = forest_model.predict(val_X)
print(mae(val_y, melbourne_predictions))
Explanation: A RandomForest is built in much the same way that a decision tree is:
End of explanation
<END_TASK>