# -*- coding: utf-8 -*-
from sklearn.linear_model import LinearRegression
import pandas as pd
import numpy as np
class TimeSeriesSplit():
def __init__(self,series,EMA):
'''
时间序列分解算法,乘法模型,由于循环波动难以确认,受随机因素影响大,不予考虑
series:时间序列
EMA:移动平均项数,也是周期的时长
'''
self.buildModel(series,EMA)
def predict(self,num):
'''
往后预测num个数,返回的是整个模型的信息
num:预测个数
'''
result = []
for i in range(num):
#季节因子
S = self.seasFactors[(i+len(self.series))%len(self.seasFactors)]
#长期趋势
T = self.regression.predict(i+len(self.series))[0][0]
result.append(T*S)
info = {
'predict':{'value':result,'desc':'往后预测的%