본문 바로가기

IT/Python

[파이썬] Model Development (Residual Plot)

What is a residual(잔여, 남은)?

 

The difference between the observed value (y) and the predicted value (Yhat) is called the residual (e). When we look at a regression plot, the residual is the distance from the data point to the fitted regression line.

 

So what is a residual plot?

A residual plot is a graph that shows the residuals on the vertical y-axis and the independent variable on the horizontal x-axis.

 

예) Residual Plot 그리기 (y=0 평균값을 중심으로 Residual을 그려준다.)

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

path = 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DA0101EN/automobileEDA.csv'
df = pd.read_csv(path)

import seaborn as sns

sns.residplot(df['highway-mpg'], df['price'])
plt.show()

>>