Visualizing predicted values
When dealing with time series data, it's useful to visualize model predictions on top of the "actual" values that are used to test the model.
In this exercise, after splitting the data (stored in the variables X and y) into training and test sets, you'll build a model and then visualize the model's predictions on top
of the testing data in order to estimate the model's performance.
This exercise is part of the course
Machine Learning for Time Series Data in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score
# Split our data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(____, ____,
train_size=.8, shuffle=False)
# Fit our model and generate predictions
model = Ridge()
model.fit(____, ____)
predictions = model.predict(____)
score = r2_score(y_test, predictions)
print(score)