시작하기무료로 시작하기

회귀 계수 시각화하기

이제 모델을 학습했으니, 계수를 시각화해 볼까요? 이는 모델의 다양한 특성이 결과에 어떤 영향을 미치는지 파악하는 데 중요한 Machine Learning 과정입니다.

시프트된 시계열 DataFrame(prices_perc_shifted)과 회귀 모델(model)이 작업 공간에 준비되어 있어요.

이번 연습에서는 계수들과 특성 이름을 받아 계수 값을 시각화하는 함수를 만들어 보겠습니다.

이 연습은 강의의 일부입니다

Python으로 배우는 시계열 데이터 Machine Learning

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

def visualize_coefficients(coefs, names, ax):
    # Make a bar plot for the coefficients, including their names on the x-axis
    ax.bar(____, ____)
    ax.set(xlabel='Coefficient name', ylabel='Coefficient value')
    
    # Set formatting so it looks nice
    plt.setp(ax.get_xticklabels(), rotation=45, horizontalalignment='right')
    return ax
코드 편집 및 실행