# Getting data
import pandas as pd
df = pd.read_csv('Advertising.csv')
X = df[['TV']]
y = df['Sales']
# Create the train and test data
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)
# Importing PredictionError visualizer
from yellowbrick.regressor import PredictionError
# Importing the Linear Regression model
from sklearn.linear_model import LinearRegression
# Creating the Prediction ErrorĀ Plot
visualizer = PredictionError(LinearRegression(), bestfit=False)
visualizer.fit(X_train, y_train)
visualizer.score(X_test, y_test)
# Saving plot in PNG format
visualizer.show(outpath="Prediction_Error_Plot.png")