데이터분석/분석-지도학습

prophet cross_validation 사용법

씩씩한 IT블로그 2021. 10. 17. 13:50
반응형

cross_validation

from fbprophet.diagnostics import cross_validation
import fbprophet as Prophet

model =  Prophet.Prophet().fit(data)

df_cv = cross_validation(model, initial='730 days', period='180 days',horizon = '365 days')

 

 

모델을 학습한 후 cross_validation으로 체크한다. 이때 parameter값들 initial, peroid, horizion의 의미를 정리한다.

 

공식문서

다음과 같이 정의 되어있다.

This cross validation procedure can be done automatically for a range of historical cutoffs using the cross_validation function. We specify the forecast horizon (horizon), and then optionally the size of the initial training period (initial) and the spacing between cutoff dates (period). By default, the initial training period is set to three times the horizon, and cutoffs are made every half a horizon.
The output of cross_validation is a dataframe with the true values y and the out-of-sample forecast values yhat, at each simulated forecast date and for each cutoff date. In particular, a forecast is made for every observed point between cutoff and cutoff + horizon. This dataframe can then be used to compute error measures of yhat vs. y.

출처 :  https://facebook.github.io/prophet/docs/diagnostics.html

 

 

설명

공식문서의 내용을 구체적으로 정리해본다

 

initial : 학습할 구간

horizon : 학습한 것을 바탕으로 예측할 구간

period : cutoff의 간격, train과 val set의 개수를 결정한다.

 

return 값(df_cv)

특정 cutoff값 하나당 다음과 같은 리턴값을 가진다

y_hat이 예측값이 된다!

반응형