Created
June 6, 2021 14:32
-
-
Save AdroitAnandAI/009f70aaff310d9a1157865e5e4654cf to your computer and use it in GitHub Desktop.
Random Forest Regressor to predict Time Series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fitting Random Forest Regression to the dataset | |
# To import sklearn's regressor | |
from sklearn.ensemble import RandomForestRegressor | |
# create regressor object | |
regressor = RandomForestRegressor(n_estimators = 100, random_state = 0) | |
# fit the regressor with x and y data | |
regressor.fit(train_X, train_y) | |
# df contains transformed feature data for 2020Q4 | |
y_pred = regressor.predict(df.values) | |
predictions = [value for value in y_pred] | |
# evaluate model using regression values | |
actual_humidity = output_2020['humidity'].values | |
mean_squared_error(actual_humidity, predictions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment