diff --git a/pyFTS/models/hofts.py b/pyFTS/models/hofts.py index 3a3c732..8ebe84f 100644 --- a/pyFTS/models/hofts.py +++ b/pyFTS/models/hofts.py @@ -166,7 +166,7 @@ class HighOrderFTS(fts.FTS): sample = data[k - self.max_lag: k] - rhs = self.partitioner.fuzzyfy(data[k+_tmp_steps], mode="sets", alpha_cut=self.alpha_cut) + rhs = self.partitioner.fuzzyfy(data[k + _tmp_steps], mode="sets", alpha_cut=self.alpha_cut) flrgs = self.generate_lhs_flrg(sample) @@ -181,12 +181,12 @@ class HighOrderFTS(fts.FTS): def generate_flrg_fuzzyfied(self, data): _tmp_steps = self.standard_horizon - 1 l = len(data) - for k in np.arange(self.max_lag, l): + for k in np.arange(self.max_lag, l - _tmp_steps): if self.dump: print("FLR: " + str(k)) sample = data[k - self.max_lag: k] - rhs = data[k+_tmp_steps] + rhs = data[k + _tmp_steps] flrgs = self.generate_lhs_flrg_fuzzyfied(sample) diff --git a/pyFTS/models/pwfts.py b/pyFTS/models/pwfts.py index 95880a1..26d68bd 100644 --- a/pyFTS/models/pwfts.py +++ b/pyFTS/models/pwfts.py @@ -137,8 +137,9 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS): self.generate_flrg_fuzzyfied(fuzz) def generate_flrg_fuzzyfied(self, data): + _tmp_steps = self.standard_horizon - 1 l = len(data) - for k in np.arange(self.max_lag, l): + for k in np.arange(self.max_lag, l - _tmp_steps): sample = data[k - self.max_lag: k] set_sample = [] for instance in sample: @@ -154,8 +155,8 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS): lhs_mv = self.pwflrg_lhs_memberhip_fuzzyfied(flrg, sample) mvs = [] - inst = data[k] - for set, mv in inst: + rhs = data[k + _tmp_steps] + for set, mv in rhs: self.flrgs[flrg.get_key()].append_rhs(set, count=lhs_mv * mv) mvs.append(mv) @@ -203,8 +204,9 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS): return flrgs def generate_flrg(self, data): + _tmp_steps = self.standard_horizon - 1 l = len(data) - for k in np.arange(self.max_lag, l): + for k in np.arange(self.max_lag, l - _tmp_steps): if self.dump: print("FLR: " + str(k)) sample = data[k - self.max_lag: k] @@ -218,7 +220,7 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS): if flrg.get_key() not in self.flrgs: self.flrgs[flrg.get_key()] = flrg; - fuzzyfied = self.partitioner.fuzzyfy(data[k], mode='both', method='fuzzy', + fuzzyfied = self.partitioner.fuzzyfy(data[k+_tmp_steps], mode='both', method='fuzzy', alpha_cut=self.alpha_cut) mvs = [] diff --git a/pyFTS/tests/general.py b/pyFTS/tests/general.py index aea02a3..f3825bc 100644 --- a/pyFTS/tests/general.py +++ b/pyFTS/tests/general.py @@ -38,8 +38,8 @@ l = len(dados) particionador = Grid.GridPartitioner(data = dados, npart = 10, func = Membership.trimf) -modelo = pwfts.ProbabilisticWeightedFTS(partitioner = particionador, order = 1) -#modelo = hofts.WeightedHighOrderFTS(partitioner = particionador, order = 1, standard_horizon=1, lags=[2]) +modelo = pwfts.ProbabilisticWeightedFTS(partitioner = particionador, order = 1, standard_horizon=3) +#modelo = hofts.WeightedHighOrderFTS(partitioner = particionador, order = 1, standard_horizon=2) #modelo = chen.ConventionalFTS(partitioner = particionador, standard_horizon=3) modelo.fit(dados)