1from sklearn.ensemble import RandomForestRegressor
2
3regressor = RandomForestRegressor(n_estimators=20, random_state=0)
4regressor.fit(X_train, y_train)
5y_pred = regressor.predict(X_test)
6
1from sklearn.model_selection import train_test_split
2
3X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
4
1from sklearn import metrics
2
3print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred))
4print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred))
5print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)))
6