95%를 넘어

Python으로 데이터 시각화 개선하기

Nick Strayer

Instructor

위: 단일 신뢰대, 아래: 3단 신뢰대로 화살표 연결

Python으로 데이터 시각화 개선하기

위: 단일 신뢰대, 아래: 3단 신뢰대, 아래쪽 90%에 화살표

Python으로 데이터 시각화 개선하기

위: 단일 신뢰대, 아래: 3단 신뢰대, 아래쪽 95%에 화살표

Python으로 데이터 시각화 개선하기

위: 단일 신뢰대, 아래: 3단 신뢰대, 아래쪽 99%에 화살표

Python으로 데이터 시각화 개선하기

위: 단일 신뢰대, 아래: 3단 신뢰대로 비교

Python으로 데이터 시각화 개선하기
# Interval size setup
sizes    = ['99%', '95%', '90%']
Z_scores = [2.58,   1.96,  1.67]
colors   = ['#fee0b6','#f1a340', '#b35806']


for size, z, color in zip(sizes, Z_scores, colors): plt.hlines(y = data.y, # Calculate lower and upper boundaries xmin = data['est'] - z*data['std_err'], xmax = data['est'] + z*data['std_err'], # Color by interval size color = color,
# Make line thicker for visibility linewidth = 7,
# Label line so legend text is clear label = size)
plt.plot('est', 'y', 'ko', data = data, label = 'Point Estimate') plt.legend()
Python으로 데이터 시각화 개선하기

90%, 95%, 99% 신뢰구간을 색으로 구분한 가로 띠 3개

Python으로 데이터 시각화 개선하기

세 신뢰구간: 위는 바깥쪽을 진하게, 가운데는 유사한 색, 아래는 안쪽을 진하게 채색

Python으로 데이터 시각화 개선하기
widths   = [    '99%',     '90%']
z_scores = [     2.58,      1.67]
colors   = ['#99d8c9', '#41ae76']

for percent, Z, color in zip(widths, z_scores, colors):
    # Set color to distinquish bands
    plt.fill_between(
        x=data.day, 
        y1=data['mean'] - Z*data['std_err'],
        y2=data['mean'] + Z*data['std_err']
        color=color,

# Lower opacity so grid can show through alpha=0.5,
# Give each band id for the legend label=percent)
Python으로 데이터 시각화 개선하기

두 신뢰대를 겹침: 안쪽은 더 진하고 작으며 바깥쪽은 더 크고 연함

Python으로 데이터 시각화 개선하기
sizes = ['99% Confidence Interval', '95%', '90%']

# Set up different line widths for intervals
widths   = [   5,     10,    15]
Z_scores = [2.58,   1.96,  1.67]

for size, z, width in zip(sizes, Z_scores, widths):
    plt.hlines(
        y = data.y, label = size,
        xmin = data['est'] - z*data['std_err'], 
        xmax = data['est'] + z*data['std_err'], 
        color = 'grey'

# Adjust line thickness by interval linewidth = width)
plt.plot('est', 'y', 'wo', data = data, label = 'Point Estimate') plt.legend()
Python으로 데이터 시각화 개선하기

3단 신뢰구간 3개: 안쪽일수록 가장 두껍고 바깥으로 갈수록 얇아짐

Python으로 데이터 시각화 개선하기

경계를 넓혀 봅시다!

Python으로 데이터 시각화 개선하기

Preparing Video For Download...