How to predict time series in scikit-learn?

后端 未结 2 499
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 17:38

Scikit-learn utilizes a very convenient approach based on fit and predict methods. I have time-series data in the format suited for fit

2条回答
  •  清歌不尽
    2020-12-22 18:15

    This might be what you're looking for, with regard to the exponentially weighted moving average:

    import pandas, numpy
    ewma = pandas.stats.moments.ewma
    EMOV_n = ewma( ys, com=2 )
    

    Here, com is a parameter that you can read about here. Then you can combine EMOV_n to Xs, using something like:

    Xs = numpy.vstack((Xs,EMOV_n))
    

    And then you can look at various linear models, here, and do something like:

    from sklearn import linear_model
    clf = linear_model.LinearRegression()
    clf.fit ( Xs, ys )
    print clf.coef_
    

    Best of luck!

提交回复
热议问题