313 KiB
313 KiB
First Order Exponentialy Weighted Fuzzy Time Series by Sadaei et al. (2013)¶
H. J. Sadaei, R. Enayatifar, A. H. Abdullah, and A. Gani, “Short-term load forecasting using a hybrid model with a refined exponentially weighted fuzzy time series and an improved harmony search,” Int. J. Electr. Power Energy Syst., vol. 62, no. from 2005, pp. 118–129, 2014.
Common Imports¶
In [1]:
import matplotlib.pylab as plt
from pyFTS.benchmarks import benchmarks as bchmk
from pyFTS.models import sadaei
%pylab inline
Data Loading¶
In [2]:
from pyFTS.data import Enrollments
enrollments = Enrollments.get_data()
Exploring the partitioning effects on original data¶
In [17]:
# Parameter c = 1.1
tmp = bchmk.simpleSearch_RMSE(enrollments, enrollments, sadaei.ExponentialyWeightedFTS,
range(4,20), [1], tam=[10, 5], parameters=1.1)
In [16]:
# Parameter c = 2
tmp = bchmk.simpleSearch_RMSE(enrollments, enrollments, sadaei.ExponentialyWeightedFTS,
range(4,20), [1], tam=[10, 5], parameters=2.0)
Exploring the partitioning effects on transformed data¶
In [19]:
from pyFTS.common import Transformations
diff = Transformations.Differential(1)
tmp = bchmk.simpleSearch_RMSE(enrollments, enrollments, sadaei.ExponentialyWeightedFTS,
range(2,10), [1], transformation=diff, tam=[10, 5], parameters=1.1)
In [20]:
tmp = bchmk.simpleSearch_RMSE(enrollments, enrollments, sadaei.ExponentialyWeightedFTS,
range(2,10), [1], transformation=diff, tam=[10, 5], parameters=2)
Comparing the partitioning schemas¶
In [7]:
from pyFTS.partitioners import Grid, Util as pUtil
fuzzy_sets = Grid.GridPartitioner(enrollments, 8)
fuzzy_sets2 = Grid.GridPartitioner(enrollments, 4, transformation=diff)
pUtil.plot_partitioners(enrollments, [fuzzy_sets,fuzzy_sets2])
Fitting a model on original data¶
In [8]:
model1 = sadaei.ExponentialyWeightedFTS("FTS", partitioner=fuzzy_sets, c=1.1)
model1.fit(enrollments)
print(model1)
Fitting a model on transformed data¶
In [9]:
model2 = sadaei.ExponentialyWeightedFTS("FTS Diff", partitioner=fuzzy_sets2, c=1.1)
model2.append_transformation(diff)
model2.fit(enrollments)
print(model2)
Using the models¶
In [10]:
model1.predict(enrollments)
Out[10]:
In [11]:
model2.predict(enrollments)
Out[11]:
Comparing the models¶
In [12]:
bchmk.plot_compared_series(enrollments, [model1, model2], bchmk.colors, intervals=False)
In [13]:
bchmk.print_point_statistics(enrollments, [model1, model2])
Residual Analysis¶
In [14]:
from pyFTS.benchmarks import ResidualAnalysis as ra
ra.plot_residuals(enrollments, [model1, model2])
In [ ]:
In [ ]: