pyFTSex/console.py
2024-08-15 12:15:32 +04:00

29 lines
840 B
Python

import matplotlib.pylab as plt
from pyFTS.models import pwfts
from pyFTS.partitioners import Grid
from service.api import influx, smoothing
data = influx.get_field()
dataFrame = smoothAPI.getTimeSeries()
dataset = dataFrame['value'].values
trainLength = int(dataset.size*0.8)
fs = Grid.GridPartitioner(data=dataset, npart=10) # Количество узлов разделения
model = pwfts.ProbabilisticWeightedFTS(partitioner=fs)
model.fit(dataset[:trainLength])
print(model)
forecasts = model.predict(dataset[trainLength:trainLength+200], type='point', steps_ahead=int(dataset.size*0.2)) #, steps_ahead=int(dataset.size*0.2)
# forecasts = model.forecast_ahead(dataset[:], trainLength)
fig, ax = plt.subplots()
ax.plot(dataset)
ax.plot( forecasts) #range(trainLength,trainLength+200),
plt.show()