Correções

This commit is contained in:
Petrônio Cândido de Lima e Silva 2016-10-25 13:53:00 -02:00
parent b58d1df00c
commit 10d1db8578
5 changed files with 12 additions and 10 deletions

View File

@ -13,18 +13,20 @@ def Teste(par):
plt.plot(x,y) plt.plot(x,y)
# Erro quadrático médio # Erro quadrático médio
def rmse(forecastions,targets): def rmse(forecasts,targets):
return np.sqrt(np.mean((forecastions-targets)**2)) return np.sqrt(np.nanmean((forecasts-targets)**2))
# Erro Percentual médio # Erro Percentual médio
def mape(forecastions,targets): def mape(forecasts,targets):
return np.mean(abs(forecastions-targets)/forecastions) return np.mean(abs(forecasts-targets)/forecasts)
def plotComparedSeries(original,fts,title): def plotComparedSeries(original,fts,title):
fig = plt.figure(figsize=[20,6]) fig = plt.figure(figsize=[20,6])
ax = fig.add_subplot(111) ax = fig.add_subplot(111)
forecasted = [fts.forecast(xx) for xx in original] forecasted = fts.forecast(original)
error = rmse(original,forecasted) #error = rmse(original[1:],forecasted[0:-1])
forecasted.insert(0,None)
#np.append(original,[None])
ax.plot(original,color='b',label="Original") ax.plot(original,color='b',label="Original")
ax.plot(forecasted,color='r',label="Predicted") ax.plot(forecasted,color='r',label="Predicted")
handles0, labels0 = ax.get_legend_handles_labels() handles0, labels0 = ax.get_legend_handles_labels()

View File

@ -48,7 +48,7 @@ class ConventionalFTS(fts.FTS):
ret = [] ret = []
for k in np.arange(1,l): for k in np.arange(0,l):
mv = common.fuzzyInstance(ndata[k], self.sets) mv = common.fuzzyInstance(ndata[k], self.sets)

View File

@ -64,7 +64,7 @@ class ImprovedWeightedFTS(fts.FTS):
ret = [] ret = []
for k in np.arange(1,l): for k in np.arange(0,l):
mv = common.fuzzyInstance(ndata[k], self.sets) mv = common.fuzzyInstance(ndata[k], self.sets)

View File

@ -61,7 +61,7 @@ class ExponentialyWeightedFTS(fts.FTS):
ret = [] ret = []
for k in np.arange(1,l): for k in np.arange(0,l):
mv = common.fuzzyInstance(ndata[k], self.sets) mv = common.fuzzyInstance(ndata[k], self.sets)

2
yu.py
View File

@ -57,7 +57,7 @@ class WeightedFTS(fts.FTS):
ret = [] ret = []
for k in np.arange(1,l): for k in np.arange(0,l):
mv = common.fuzzyInstance(ndata[k], self.sets) mv = common.fuzzyInstance(ndata[k], self.sets)