-#!/usr/bin/python
-# -*- coding: utf8 -*-
+"""
+EnsembleFTS wraps several FTS methods to ensemble their forecasts, providing point,
+interval and probabilistic forecasting.
+
+Silva, P. C. L et al. Probabilistic Forecasting with Seasonal Ensemble Fuzzy Time-Series
+XIII Brazilian Congress on Computational Intelligence, 2017. Rio de Janeiro, Brazil.
+"""
+
importnumpyasnpimportpandasaspd
@@ -96,7 +102,7 @@
"""def__init__(self,**kwargs):super(EnsembleFTS,self).__init__(**kwargs)
- self.shortname="Ensemble FTS"
+ self.shortname="EnsembleFTS"self.name="Ensemble FTS"self.flrgs={}self.has_point_forecasting=True
@@ -108,13 +114,16 @@
self.parameters=[]"""A list with the parameters for each component model"""self.alpha=kwargs.get("alpha",0.05)
+ """The quantiles """self.point_method=kwargs.get('point_method','mean')
+ """The method used to mix the several model's forecasts into a unique point forecast. Options: mean, median, quantile"""self.interval_method=kwargs.get('interval_method','quantile')
+ """The method used to mix the several model's forecasts into a interval forecast. Options: quantile, extremum, normal"""self.order=1
[docs]defappend_model(self,model):"""
- Append a new model to the ensemble
+ Append a new trained model to the ensemble :param model: FTS model
@@ -341,6 +350,9 @@
[docs]classAllMethodEnsembleFTS(EnsembleFTS):
+ """
+ Creates an EnsembleFTS with all point forecast methods, sharing the same partitioner
+ """def__init__(self,**kwargs):super(AllMethodEnsembleFTS,self).__init__(**kwargs)self.min_order=3
diff --git a/docs/build/html/_modules/pyFTS/models/ensemble/multiseasonal.html b/docs/build/html/_modules/pyFTS/models/ensemble/multiseasonal.html
index e04fd2f..3cd0f9b 100644
--- a/docs/build/html/_modules/pyFTS/models/ensemble/multiseasonal.html
+++ b/docs/build/html/_modules/pyFTS/models/ensemble/multiseasonal.html
@@ -72,8 +72,10 @@
Source code for pyFTS.models.ensemble.multiseasonal
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+"""
+Silva, P. C. L et al. Probabilistic Forecasting with Seasonal Ensemble Fuzzy Time-Series
+XIII Brazilian Congress on Computational Intelligence, 2017. Rio de Janeiro, Brazil.
+"""importnumpyasnpfrompyFTS.commonimportUtilascUtil
diff --git a/docs/build/html/_modules/pyFTS/models/incremental/Retrainer.html b/docs/build/html/_modules/pyFTS/models/incremental/Retrainer.html
new file mode 100644
index 0000000..79f0713
--- /dev/null
+++ b/docs/build/html/_modules/pyFTS/models/incremental/Retrainer.html
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+ pyFTS.models.incremental.Retrainer — pyFTS 1.2.3 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Source code for pyFTS.models.incremental.Retrainer
+"""
+Meta model that wraps another FTS method and continously retrain it using a data window with the most recent data
+"""
+
+importnumpyasnp
+frompyFTS.commonimportFuzzySet,FLR,fts,flrg
+frompyFTS.partitionersimportGrid
+
+
+
[docs]classRetrainer(fts.FTS):
+ """
+ Meta model for incremental/online learning
+ """
+ def__init__(self,**kwargs):
+ super(Retrainer,self).__init__(**kwargs)
+
+ self.partitioner_method=kwargs.get('partitioner_method',Grid.GridPartitioner)
+ """The partitioner method to be called when a new model is build"""
+ self.partitioner_params=kwargs.get('partitioner_params',{'npart':10})
+ """The partitioner method parameters"""
+ self.partitioner=None
+ """The most recent trained partitioner"""
+
+ self.fts_method=kwargs.get('fts_method',None)
+ """The FTS method to be called when a new model is build"""
+ self.fts_params=kwargs.get('fts_params',{})
+ """The FTS method specific parameters"""
+ self.model=None
+ """The most recent trained model"""
+
+ self.window_length=kwargs.get('window_length',100)
+ """The memory window length"""
+ self.auto_update=False
+ """If true the model is updated at each time and not recreated"""
+ self.is_high_order=True
+
+
+
+ def__str__(self):
+ """String representation of the model"""
+
+ returnstr(self.model)
+
+ def__len__(self):
+ """
+ The length (number of rules) of the model
+
+ :return: number of rules
+ """
+ returnlen(self.model)
[docs]defcumulative(self,values):"""
- Return the cumulative probability densities for the input values
+ Return the cumulative probability densities for the input values,
+ such that F(x) = P(X <= x) :param values: A list of input values :return: The cumulative probability densities for the input values
@@ -275,7 +276,8 @@
[docs]defquantile(self,values):"""
- Return the quantile values for the input values
+ Return the Universe of Discourse values in relation to the quantile input values,
+ such that Q(tau) = min( {x | F(x) >= tau }) :param values: input values :return: The list of the quantile values for the input values
@@ -296,7 +298,7 @@
[docs]defentropy(self):"""
- Return the entropy of the probability distribution, H[X] =
+ Return the entropy of the probability distribution, H(P) = E[ -ln P(X) ] = - ∑ P(x) log ( P(x) ) :return:the entropy of the probability distribution """
@@ -306,7 +308,8 @@
[docs]defcrossentropy(self,q):"""
- Cross entropy between the actual probability distribution and the informed one.
+ Cross entropy between the actual probability distribution and the informed one,
+ H(P,Q) = - ∑ P(x) log ( Q(x) ) :param q: a probabilistic.ProbabilityDistribution object :return: Cross entropy between this probability distribution and the given distribution
@@ -318,6 +321,7 @@
[docs]defkullbackleiblerdivergence(self,q):""" Kullback-Leibler divergence between the actual probability distribution and the informed one.
+ DKL(P || Q) = - ∑ P(x) log( P(X) / Q(x) ) :param q: a probabilistic.ProbabilityDistribution object :return: Kullback-Leibler divergence
@@ -328,7 +332,7 @@