Skip to content

Instantly share code, notes, and snippets.

@AdroitAnandAI
Created June 6, 2021 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdroitAnandAI/009f70aaff310d9a1157865e5e4654cf to your computer and use it in GitHub Desktop.
Save AdroitAnandAI/009f70aaff310d9a1157865e5e4654cf to your computer and use it in GitHub Desktop.
Random Forest Regressor to predict Time Series
# 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