[Blog] Time Series Transformation Package : scalecast
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 : κΈ°λ§μ μΌλ‘