季节性运行时季节始终是7。这是为什么?
我一直在大约20个完全不同的数据集中从统计模型中运行pesional_decompose()。在看日期频率的数据集时,季节性是7吗?
这是一个图片作为一个数据集分解的示例。我放大了季节性,以便您可以看到它再次是7天:
为什么总是7天?我不会期望它总是7天,并且数据集彼此之间的不同,所以到现在为止,我认为这是完全巧合,或者这是因为sensional_decompose()。
但是,查看统计模型文档中的时令_decostose(),它使用loess来找出季节性。如果我看公式,它应该能够找到季节性的不同频率。我只需要验证我在这里没有错:我所有的数据集都产生7天的季节性频率是纯粹的巧合吗?
I have been running seasonal_decompose() from the statsmodels on about 20 totally different datasets. Is it standard that the seasonality is 7 when looking at a dataset with day frequency?
Here is a picture as an example of one dataset decomp. I zoomed in on the seasonality so that you can see that it is again 7 days:
Why is it always 7 days though? I wouldn't expect it to be always 7 days and the datasets are all different from each other, so by now I think that either this is total coincidence or this is because of seasonal_decompose().
But looking at how seasonal_decompose() in the statsmodels documentation , it uses LOESS to figure out the seasonality. If I look at the formula, it should be able to find different frequencies of the seasonality. I just need to verify that I am not wrong here: Is it pure coincidence that all of my datasets produce a 7 day frequency of the seasonality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,
pensional_decompose
与黄土无关,对于基于loess的分解,您需要使用statsmodels.tsa.tsa.seasonal.stl
。pensional_decostose
均不会以任何方式根据数据推断周期性。您只有两个选项:期间
参数ofient
atnone
的参数。在这种情况下,您必须将pandas
带有DateTime索引的DataFramesensional_decostose
,并且会从DateTime索引频率标签中推断出周期性,否则会丢弃错误。它首先获取频率标签:pfreq = getAttr(getAttr(x,“ index”,none),“ peashred_freq”,none)
(在您的情况下,频率标签将为'd',意思是每天),然后使用
将转换为<statsmodels.tsa.tsatools.freq_to_period
'd'd'> 7
,这将用作周期性,因此您获得的结果)First of all,
seasonal_decompose
has nothing to do with LOESS, for decomposition based on LOESS you need to usestatsmodels.tsa.seasonal.STL
.seasonal_decompose
does not infer periodicity based on data in any way. You only have two options:period
argumentperiod
argument atNone
. In this case you have to feedpandas
dataframe with datetime index toseasonal_decompose
, and periodicity will be inferred from datetime index frequency label, otherwise it will throw an error. It first fetches frequency label:pfreq = getattr(getattr(x, "index", None), "inferred_freq", None)
(in your case frequency label will be'D'
, meaning daily), then it converts it to periodicity usingstatsmodels.tsa.tsatools.freq_to_period
(in your case frequency label'D'
will be converted to7
, and that will be used as periodicity, hence the results you get)