TypeError:siperional_decompose()获得了意外的关键字参数' ofere'

发布于 2025-01-31 04:08:14 字数 644 浏览 2 评论 0原文

我正在尝试使用DateTime索引来消化时间序列数据。我将在项目中使用期限,但这给了我一个错误,说没有参数命名时期。我找不到任何东西。但是我看到在StatsModel网站上提到了间隔,有人知道如何克服这种情况吗?

 from statsmodels.tsa.seasonal import seasonal_decompose
# Multiplicative Decomposition 
decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
decomp_mul.plot()
plt.show()

TypeError Trackback(最近的最新通话) 在 () 2 3#乘法分解 ----> 4 decomp_mul = siensional_decompose(df ['nyemp'],model ='乘法',extrapaly_trend ='freq',ofent = 365) 5 decomp_mul.plot() 6 plt.show()

typeError:simestal_decompose()有一个意外的关键字参数“ ofere”

我使用Google colab

I'm trying to digest time series data with datetime index. I'm going to use period in my project, but it gives me an error saying there is no argument named period. I couldn't find anything for that. But I see that the interval is mentioned on the statsmodel website, does anyone know how I can overcome this situation?

 from statsmodels.tsa.seasonal import seasonal_decompose
# Multiplicative Decomposition 
decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
decomp_mul.plot()
plt.show()

TypeError Traceback (most recent call last)
in ()
2
3 # Multiplicative Decomposition
----> 4 decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
5 decomp_mul.plot()
6 plt.show()

TypeError: seasonal_decompose() got an unexpected keyword argument 'period'

i use google colab

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

提笔书几行 2025-02-07 04:08:14

#prueba conestecódigoque mefuncionóencolab
#freq = 12 es elnúmerode ofercos en unañopara caso

la info la gotuve en el libro Mastering python for Finance de James Ma Weiming(SegundaEdición,Pag 202)
te dejo dice dice dice conelCódigo

季节性分解

分解涉及建模趋势季节性,然后将其删除。我们可以使用statsmodel.tsa.saseanal模块使用移动平均值来建模非组织时间序列数据集并删除其趋势和季节性组件。

通过重复我们的df_log在上一节中包含数据集的对数的变量,我们得到以下内容:

from statsmodels.tsa.seasonal import seasonal_decompose 
decompose_result = seasonal_decompose(df_log.dropna(), freq=12) 
df_trend = decompose_result.trend 
df_season = decompose_result.seasonal 
df_residual = decompose_result.resid 

pensional_decompose() /code>需要一个参数,freq,它是一个整数值,指定每个季节周期的周期数。

由于我们正在使用每月数据,因此我们预计 在季节性的年份。
该方法返回一个具有三个属性的对象,主要是趋势和季节性成分,以及最终的熊猫系列数据,其趋势和季节性成分已被删除。

有关 statsmodels.t sa.seasonal模块的更多信息可以找到在这里

让我们通过运行以下python code可视化不同的图:

plt.rcParams['figure.figsize'] = (12, 8) 
fig = decompose_result.plot()

#Prueba con este código que me funcionó en colab
#freq=12 es el número de periodos en un año para este caso

La info la obtuve en el libro Mastering Python for Finance de James Ma Weiming (segunda edición, pag 202)
Te dejo lo que dice junto con el código

Seasonal decomposing

Decomposing involves modeling both the trend and seasonality, and then removing them. We can use the statsmodel.tsa.seasonal module to model a nonstationary time series dataset using moving averages and remove its trend and seasonal components.

By reusing our df_log variable containing the logarithm of our dataset from the previous section, we get the following:

from statsmodels.tsa.seasonal import seasonal_decompose 
decompose_result = seasonal_decompose(df_log.dropna(), freq=12) 
df_trend = decompose_result.trend 
df_season = decompose_result.seasonal 
df_residual = decompose_result.resid 

The seasonal_decompose() method of statsmodels.tsa.seasonal requires a parameter, freq, which is an integer value specifying the number of periods per seasonal cycle.

Since we are using monthly data, we expect 12 periods in a seasonal year.
The method returns an object with three attributes, mainly the trend and seasonal components, as well as the final pandas series data with its trend and seasonal components removed.

More information on the seasonal_decompose() method of the statsmodels.t sa.seasonal module can be found here

Let's visualize the different plots by running the following Python code:

plt.rcParams['figure.figsize'] = (12, 8) 
fig = decompose_result.plot()
情深如许 2025-02-07 04:08:14

更新您的问:
我今天检查了一下:注意:STATSMODELS的siensional_decompose()方法的频率参数已被弃用,并用TDS网页中的周期参数替换。
和...
该日期应为DateTime格式,需要使用.set_index(),例如DF.Set_index('date',inplace = true)设置为索引。在您的案例日期为t(根据您的数据集)

Updating your Q:
I checked this today: Note: The frequency parameter of statsmodels’ seasonal_decompose() method has been deprecated and replaced with the period parameter in TDS webpage.
And...
The date should be in datetime format and need to be set as index using .set_index(), e.g., df.set_index('Date', inplace=True). In your case Date is t (as per your dataset)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文