여러 시계열 간의 상관관계
이전 연습 문제에서, jobs DataFrame의 각 시계열에서 seasonal 성분을 추출해 seasonality_df라는 새 DataFrame에 저장했어요. 구인·고용 데이터에서는 계절성의 양상을 비교해 보면 어떤 산업이 서로 가장 비슷하거나 다른지 파악하는 데 도움이 될 수 있어요.
이를 위해 seasonality_df DataFrame을 사용해 데이터셋의 각 시계열 간 상관관계를 계산할 수 있어요. 이 연습 문제에서는 4장에서 배운 내용을 활용해 seasonality_df DataFrame의 시계열들 간 상관관계로 클러스터맵 시각화를 만들어 보겠습니다.
이 연습은 강의의 일부입니다
Python으로 시계열 데이터 시각화
연습 안내
seasonality_dfDataFrame의 모든 열 간 상관관계를 spearman 방법으로 계산하고 결과를seasonality_corr에 할당하세요.- 상관행렬로 새로운 클러스터맵을 만드세요.
- Government와 Education & Health 산업의 계절성 간 상관계수 값을 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Get correlation matrix of the seasonality_df DataFrame
seasonality_corr = ____
# Customize the clustermap of the seasonality_corr correlation matrix
fig = ____(____, annot=True, annot_kws={"size": 4}, linewidths=.4, figsize=(15, 10))
plt.setp(fig.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
plt.setp(fig.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
plt.show()
# Print the correlation between the seasonalities of the Government and Education & Health industries
print(____)