1. Box Plot
1) Simple Plot Graph
samples = [1,7,9,16,36,39,45,45,46,48,51,100,101]
tmp_y = [1]*len(samples)
import matplotlib.pyplot as plt
plt.figure(figsize=(12,6))
plt.scatter(samples, tmp_y)
plt.grid()
plt.show()
2) Box Plot 지표 찾기
# 중앙값, Q2
np.median(samples)
# 45.0
# Q1
np.percentile(samples, 25)
# 16.0
# Q3
np.percentile(samples, 75)
# 48.0
# iqr
iqr = np.percentile(samples, 75) - np.percentile(samples, 25)
iqr *1.5
# 48.0
3) 그래프에 지표 그리기
q1 = np.percentile(samples, 25)
q2 = np.median(samples)
q3 = np.percentile(samples, 75)
iqr = q3 - q1
upper_fence = q3 + iqr*1.5
lower_fence = q1 - iqr*1.5
plt.figure(figsize=(12,4))
plt.scatter(samples, tmp_y)
plt.axvline(x = q1, color='black')
plt.axvline(x = q2, color='red')
plt.axvline(x = q3, color='black')
plt.axvline(x = upper_fence, color='black', ls='dashed')
plt.axvline(x = lower_fence, color='black', ls='dashed')
plt.grid()
plt.show()