當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python cuml.ExponentialSmoothing用法及代碼示例

用法:

class cuml.ExponentialSmoothing(endog, *, seasonal='additive', seasonal_periods=2, start_periods=2, ts_num=1, eps=0.00224, handle=None, verbose=False, output_type=None)

實施HoltWinters時間序列分析模型,用於預測時間序列中的未來條目以及提供 index 平滑,其中權重分配給曆史數據,影響呈 index 下降。這是通過分析數據的三個組成部分來完成的:水平、趨勢和季節性。

參數

endogarray-like(設備或主機)

可接受的格式:cuDF DataFrame cuDF 係列、NumPy ndarray、Numba 設備 ndarray、cuda 數組接口兼容數組,如 CuPy 注意:cuDF DataFrame 類型假定數據在列中,而所有其他數據類型假定數據在行中.要操作的內生數據集。

seasonal‘additive’, ‘add’, ‘multiplicative’, ‘mul’(默認 = ‘additive’)

季節性趨勢是應該加法還是乘法計算。

seasonal_periodsint(默認值=2)

數據的季節性(重複頻率)。對於每月數據,這應該是 12,對於每周數據,這應該是 7。

start_periodsint(默認值=2)

用於季節性種子值的季節數

ts_numint(默認值=1)

在 endog 參數中傳遞的不同時間序列的數量。

epsnp.number > 0(默認=2.24e-3)

梯度下降應該達到的準確度。請注意,更改此值可能會影響預測結果。

handlecuml.Handle

指定 cuml.handle 保存用於此模型中計算的內部 CUDA 狀態。最重要的是,這指定了將用於模型計算的 CUDA 流,因此用戶可以通過在多個流中創建句柄在不同的流中同時運行不同的模型。如果為 None,則創建一個新的。

verboseint 或布爾值,默認=False

設置日誌記錄級別。它必須是 cuml.common.logger.level_* 之一。有關詳細信息,請參閱詳細級別。

output_type{‘input’, ‘cudf’, ‘cupy’, ‘numpy’, ‘numba’},默認=無

用於控製估計器的結果和屬性的輸出類型的變量。如果為 None,它將繼承在模塊級別設置的輸出類型 cuml.global_settings.output_type 。有關詳細信息,請參閱輸出數據類型配置。

注意

Known Limitations:statsmodels.holtwinters.ExponentialSmoothing 模型相比,此版本的ExponentialSmoothing 目前僅提供有限數量的函數。值得注意的是,它缺少:

此外,請注意,此模型中可能存在浮點不穩定問題。 endog 中的小值可能會導致錯誤的結果。有關詳細信息,請參閱https://github.com/rapidsai/cuml/issues/888

Known Differences: 此版本的ExponentialSmoothing 在其他一些小方麵與 statsmodel 不同:

  • 不能通過趨勢分量或阻尼趨勢分量
  • 此版本可以采用附加參數 epsstart_periodsts_numhandle
  • 分數返回 SSE 而不是梯度 logL https://github.com/rapidsai/cuml/issues/876
  • 此版本提供get_level()、get_trend()、get_season()

例子

from cuml import ExponentialSmoothing
import cudf
import numpy as np
data = cudf.Series([1, 2, 3, 4, 5, 6,
                    7, 8, 9, 10, 11, 12,
                    2, 3, 4, 5, 6, 7,
                    8, 9, 10, 11, 12, 13,
                    3, 4, 5, 6, 7, 8, 9,
                    10, 11, 12, 13, 14],
                    dtype=np.float64)
cu_hw = ExponentialSmoothing(data, seasonal_periods=12)
cu_hw.fit()
cu_pred = cu_hw.forecast(4)
print('Forecasted points:', cu_pred)

輸出:

Forecasted points :
0    4.000143766093652
1    5.000000163513641
2    6.000000000174092
3    7.000000000000178

屬性

SSE
forecasted_points
level
season
trend

相關用法


注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cuml.ExponentialSmoothing。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。