I am having time-series data I am trying to predict spot prices for next-day. My data looks like:
I did groupby on f_area and I end up with multiindex. Now I am trying to do predictions using RandomForestRegressor.
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
y = area3['y'].values
X = area3[['f_price', 'day_of_week', 'day_of_month']]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42)
model = RandomForestRegressor()
model = model.fit(X_train, y_train)
y_pred = model.predict(X_test)
Now when I try to plot y_test(actual values) and y_pred(predicted values)
fig, ax = plt.subplots()
ax.plot(y_test)
ax.plot(y_pred)
What I want need is to have date on X axis and I am unable to so it because of the multi-index. How can I do this or remove the multiindex? I tried to remove the multiindex via reset_index but it doesn't work in my case Thanks
