Inizia subitoInizia gratis

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.

Questo esercizio fa parte del corso

Machine Learning for Time Series Data in Python

Visualizza corso

esercizio interattivo pratico

Prova questo esercizio completando questo codice di esempio.

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)
Modifica ed esegui il codice