季节性运行时季节始终是7。这是为什么?

发布于 2025-01-22 22:38:45 字数 511 浏览 0 评论 0原文

我一直在大约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:

enter image description here

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 技术交流群。

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

发布评论

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

评论(1

能否归途做我良人 2025-01-29 22:38:45

首先,pensional_decompose与黄土无关,对于基于loess的分解,您需要使用statsmodels.tsa.tsa.seasonal.stlpensional_decostose均不会以任何方式根据数据推断周期性。您只有两个选项:

  1. 状态周期性明确使用期间参数
  2. 不陈述周期性,留下ofient at none的参数。在这种情况下,您必须将pandas带有DateTime索引的DataFrame sensional_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 use statsmodels.tsa.seasonal.STL. seasonal_decompose does not infer periodicity based on data in any way. You only have two options:

  1. State periodicity explicitly using period argument
  2. Do not state periodicity, leaving period argument at None. In this case you have to feed pandas dataframe with datetime index to seasonal_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 using statsmodels.tsa.tsatools.freq_to_period (in your case frequency label 'D' will be converted to 7, and that will be used as periodicity, hence the results you get)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文