IFTS high order 100% funcional

This commit is contained in:
Petrônio Cândido de Lima e Silva 2016-10-26 12:08:09 -02:00
parent b613c6db8a
commit c1c8f90fc9
2 changed files with 23 additions and 6 deletions

View File

@ -20,22 +20,34 @@ def rmse(forecasts,targets):
def mape(forecasts,targets): def mape(forecasts,targets):
return np.mean(abs(forecasts-targets)/forecasts) return np.mean(abs(forecasts-targets)/forecasts)
def plotComparedSeries(original,fts,title): def plotComparedSeries(original,fts,parameters):
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(original) forecasted = fts.forecast(original)
#error = rmse(original[1:],forecasted[0:-1]) #error = rmse(original[1:],forecasted[0:-1])
forecasted.insert(0,None)
#np.append(original,[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") if fts.isInterval:
lower = [kk[0] for kk in forecasted]
upper = [kk[1] for kk in forecasted]
ax.set_ylim([min(lower),max(upper)])
for k in np.arange(0,fts.order):
lower.insert(0,None)
upper.insert(0,None)
ax.plot(lower,color='r',label="Predicted")
ax.plot(upper,color='r')
else:
forecasted.insert(0,None)
ax.plot(forecasted,color='r',label="Predicted")
ax.set_ylim([np.nanmin(forecasted),np.nanmax(forecasted)])
handles0, labels0 = ax.get_legend_handles_labels() handles0, labels0 = ax.get_legend_handles_labels()
ax.legend(handles0,labels0) ax.legend(handles0,labels0)
ax.set_title(title) ax.set_title(fts.name)
ax.set_ylabel('F(T)') ax.set_ylabel('F(T)')
ax.set_xlabel('T') ax.set_xlabel('T')
ax.set_xlim([0,len(original)]) ax.set_xlim([0,len(original)])
ax.set_ylim([min(original),max(original)])
def plotCompared(original,forecasted,labels,title): def plotCompared(original,forecasted,labels,title):
fig = plt.figure(figsize=[13,6]) fig = plt.figure(figsize=[13,6])

View File

@ -68,12 +68,16 @@ class IntervalFTS(hofts.HighOrderFTS):
lags[count] = idx lags[count] = idx
count = count + 1 count = count + 1
#print(lags)
# Constrói uma árvore com todos os caminhos possíveis # Constrói uma árvore com todos os caminhos possíveis
root = tree.FLRGTreeNode(None) root = tree.FLRGTreeNode(None)
self.buildTree(root,lags,0) self.buildTree(root,lags,0)
#print(root)
# Traça os possíveis caminhos e costrói as HOFLRG's # Traça os possíveis caminhos e costrói as HOFLRG's
for p in root.paths(): for p in root.paths():
@ -104,6 +108,7 @@ class IntervalFTS(hofts.HighOrderFTS):
count = count + 1 count = count + 1
# gerar o intervalo # gerar o intervalo
ret.append( [ sum(lo), sum(up) ] ) norm = sum(mvs)
ret.append( [ sum(lo)/norm, sum(up)/norm ] )
return ret return ret