python中的时间序列分析包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12726432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 11:43:02  来源:igfitidea点击:

Package for time series analysis in python

pythonpandastime-seriesforecastingstatsmodels

提问by foc

I am working on time series in python. The libraries which I found useful and promising are

我正在用 python 处理时间序列。我发现有用且有前途的库是

  • pandas;
  • statsmodel (for ARIMA);
  • simple exponential smoothing is provided from pandas.
  • 熊猫;
  • 统计模型(用于 ARIMA);
  • pandas 提供了简单的指数平滑。

Also for visualization: matplotlib

也用于可视化:matplotlib

Does anyone know a library for exponential smoothing?

有谁知道指数平滑库?

回答by jseabold

Pandas has exponentially weighted moving moment functions

Pandas 具有指数加权的移动力矩函数

http://pandas.pydata.org/pandas-docs/dev/computation.html?highlight=exponential#exponentially-weighted-moment-functions

http://pandas.pydata.org/pandas-docs/dev/computation.html?highlight=exponential#exponentially-weighted-moment-functions

By the way, there shouldn't be any functionality leftover in the scikits.timeseries package that is not also in pandas.

顺便说一句,在 scikits.timeseries 包中不应该有任何剩余的功能,而 Pandas 中也没有。

Edit: Since this is still a popular question, there is now a work in progress pull request to add more fully featured exponential smoothing to statsmodels here

编辑:由于这仍然是一个受欢迎的问题,现在有一个正在进行的拉取请求,以在此处向 statsmodels 添加更多功能齐全的指数平滑

回答by foc

For triple I found on web this http://adorio-research.org/wordpress/?p=1230

对于三重我在网上找到这个http://adorio-research.org/wordpress/?p=1230

回答by RParadox

Somehow some questions got merged or deleted, so I'll post my answer here.

不知何故,有些问题被合并或删除了,所以我会在这里发布我的答案。

Exp smoothing in Python natively.

原生 Python 中的 Exp 平滑。

'''
simple exponential smoothing
go back to last N values
y_t = a * y_t + a * (1-a)^1 * y_t-1 + a * (1-a)^2 * y_t-2 + ... + a*(1-a)^n * y_t-n
'''
from random import random,randint

def gen_weights(a,N):
    ws = list()
    for i in range(N):
        w = a * ((1-a)**i)
        ws.append(w)
    return ws

def weighted(data,ws):
    wt = list()
    for i,x in enumerate(data):
        wt.append(x*ws[i])
    return wt

N = 10
a = 0.5
ws = gen_weights(a,N)
data = [randint(0,100) for r in xrange(N)]
weighted_data = weighted(data,ws)
print 'data: ',data
print 'weights: ',ws
print 'weighted data: ',weighted_data
print 'weighted avg: ',sum(weighted_data)

回答by Chitrasen

you can predict the future values using Pandas Exponentially-weighted moving average http://pandas.pydata.org/pandas-docs/stable/generated/pandas.stats.moments.ewma.htmlas

您可以使用 Pandas 指数加权移动平均线预测未来值http://pandas.pydata.org/pandas-docs/stable/generated/pandas.stats.moments.ewma.html作为

from pandas.stats.moments import ewma
import numpy as np

pred_period = 12

def predict(x,span,periods = pred_period):     
    x_predict = np.zeros((span+periods,))
    x_predict[:span] = x[-span:]
    pred =  ewma(x_predict,span)[span:]

    return pred