时间序列-如何在超级平滑python中添加时间索引
发布时间:2022-04-01 10:53:34 276
相关标签: # 数据
我有一个平滑timeseries AirPassenger数据的代码:https://www.kaggle.com/datasets/rakannimer/air-passengers
TIMEINDEX="Month"
TARGET="#Passengers"
df = pd.read_csv(filename_, parse_dates=[TIMEINDEX])
df.sort_values(by=TIMEINDEX, inplace=True)
df.set_index(TIMEINDEX, inplace=True, drop=True)
y = df[TARGET].values
# fit the supersmoother model
model = SuperSmoother()
model.fit(df.index, y)
yfit = model.predict(df.index)
我正在努力让它与df相匹配。索引和y值model.fit(df.index, y)
。但它会抛出下面给出的错误:
Traceback (most recent call last):
File "C:/my_tests/stationary_test.py", line 46, in
model.fit(df.index, y)
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\smoother.py", line 32, in fit
self._fit(self.t, self.y, self.dy)
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\supersmoother.py", line 62, in _fit
for smoother in self.primary_smooths])
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\supersmoother.py", line 62, in
for smoother in self.primary_smooths])
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\smoother.py", line 53, in cv_values
return self._cv_values(cv)
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\smoother.py", line 124, in _cv_values
span=self.span_int(), period=self.period)
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\utils.py", line 176, in linear_smooth
subtract_mid=cv, period=period)
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\windowed_sum.py", line 188, in windowed_sum
for a, tp in zip(arrays, tpowers)]
File "C:\Miniconda3\envs\test\lib\site-packages\supersmoother\windowed_sum.py", line 188, in
for a, tp in zip(arrays, tpowers)]
TypeError: ufunc 'power' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''.
有没有办法为supersmoother提供时间索引?谢谢
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报