๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽธ ๊ธฐํƒ€/๐ŸŽƒ ์˜์–ด

[Blog] Time Series Transformation Package : scalecast

by isdawell 2023. 1. 27.
728x90

 

 https://medium.com/towards-data-science/time-series-transformations-and-reverting-made-easy-f4f768c18f63

 

Time Series Transformations (and Reverting) Made Easy

Exploring transformations for time series and how to revert them with scalecast in Python

towardsdatascience.com

 

 

 

 

 

 

๐Ÿ‘€ Summary 


 

โ–ธ Stationarity is an important factor in forecasting time series data. It means that its tendency to return to its mean value over time. (ํ‰๊ท ๊ณผ ๋ถ„์‚ฐ์ด ์ผ์ •ํ•˜๊ณ , ํŠน์ •ํ•œ ์ถ”์„ธ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š” ์„ฑ์งˆ)

 

โ–ธ ARIMA, Holt-Winters, Exponential Smoothing and others → do not necessarily require stationary data 

    • Ex. ARIMA ๋ชจ๋ธ์˜ ๊ฒฝ์šฐ ์ฐจ๋ถ„์„ ํ†ตํ•ด ์ •์ƒ์„ฑ์„ ๋งŒ์กฑ์‹œํ‚ด 

 

โ–ธ However, popular ML model like XGBoost hos no regards for series' stationarity → need to apply transformation 

 

 

 

 

๐Ÿ”น scalecast python packages 

 

• ๋น„์ •์ƒ ์‹œ๊ณ„์—ด ๋ฐ์ดํ„ฐ๋ฅผ ๋ณ€ํ˜•์‹œํ‚ค๋Š”๋ฐ ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ 

 

pip install --upgrade scalecast

from scalecast.Forecaster import Forecaster
from scalecast.SeriesTransformer import SeriesTransformer

 

 

• Transformer ์ ์šฉ 

 

#

data = pd.read_csv('AirPassengers.csv')

f = Forecaster(
    current_dates = data['Month'],
    y = data['#Passengers'],
    future_dates = 24,
) 

transformer = SeriesTransformer(f)



# ๐Ÿ‘‰ ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ์ฐจ๋ถ„ 

f = transformer.DiffTransform(12) # 12 periods is one seasonal difference for monthly data
f = transformer.DetrendTransform()

 

 

 

• ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ์ฐจ๋ถ„ ๋ฐฉ๋ฒ•๋“ค์„ ์ ์šฉ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Œ :  first differencing, second differencing and beyond, seasonal differencing, linear detrending, polynomial detrending, logarithmic detrending, scaling, boxcox transformations ... 

 

 

https://github.com/mikekeith52/scalecast

 

GitHub - mikekeith52/scalecast: The practitioner's forecasting library

The practitioner's forecasting library. Contribute to mikekeith52/scalecast development by creating an account on GitHub.

github.com

 

 

์˜ˆ์ธก๋ชจ๋ธ์„ ๋ฐ”๋กœ ๋ถˆ๋Ÿฌ์™€ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜๋„ ์žˆ์œผ๋ฉฐ, ์ฐจ๋ถ„ ์ด์ „์˜ ๋ฐ์ดํ„ฐ๋กœ ๋˜๋Œ๋ฆด ์ˆ˜๋„ ์žˆ๋‹ค. ๋˜ํ•œ Auto-transforming ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ด, ๊ฐ€์žฅ ์ตœ์ ์˜ ์„ฑ๋Šฅ์„ ๋ณด์ด๋Š” ๋ณ€ํ˜• ๋ฐฉ๋ฒ•์„ ์ถ”์ฒœ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ ๋˜ํ•œ ์กด์žฌํ•œ๋‹ค. 

 

 

from scalecast.util import find_optimal_transformation

 

 

 

 

๐Ÿ“š Vocab 


• revert : ์›๋ž˜ ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ€๋‹ค 

• spurious : ๊ฐ€์งœ์˜, ๋น„๋…ผ๋ฆฌ์ ์ธ

• deceptively : ๊ธฐ๋งŒ์ ์œผ๋กœ

 

 

 

728x90

๋Œ“๊ธ€