#NEWLINE# def predict( self , h = 5 , past_values = 20 , intervals = True , **kwargs ) : #NEWLINE# #INDENT# figsize = kwargs . get ( 'figsize' , ( 10 , 7 ) ) #NEWLINE# ' Makes forecast with the estimated model\n\n\t\tParameters\n\t\t----------\n\t\th : int (default : 5)\n\t\t\tHow many steps ahead would you like to forecast?\n\n\t\tpast_values : int (default : 20)\n\t\t\tHow many past observations to show on the forecast graph?\n\n\t\tintervals : Boolean\n\t\t\tWould you like to show prediction intervals for the forecast?\n\n\t\tReturns\n\t\t----------\n\t\t- Plot of the forecast\n\t\t- Error bars, forecasted_values, plot_values, plot_index\n\t\t' #NEWLINE# if ( len ( self . params ) == 0 ) : #NEWLINE# #INDENT# raise Exception ( 'No parameters estimated!' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( mu , Y ) = self . model ( self . params ) #NEWLINE# date_index = self . shift_dates ( h ) #NEWLINE# t_params = self . transform_parameters ( ) #NEWLINE# mean_values = self . mean_prediction ( mu , Y , h , t_params ) #NEWLINE# sim_values = self . sim_prediction ( mu , Y , h , t_params , 15000 ) #NEWLINE# ( error_bars , forecasted_values , plot_values , plot_index ) = self . summarize_simulations ( mean_values , sim_values , date_index , h , past_values ) #NEWLINE# plt . figure ( figsize = figsize ) #NEWLINE# if ( intervals == True ) : #NEWLINE# #INDENT# alpha = [ ( ( 0.15 * i ) / float ( 100 ) ) for i in range ( 50 , 12 , ( - 2 ) ) ] #NEWLINE# for ( count , pre ) in enumerate ( error_bars ) : #NEWLINE# #INDENT# plt . fill_between ( date_index [ ( ( len ( date_index ) - h ) - 1 ) : len ( date_index ) ] , ( forecasted_values - pre ) , ( forecasted_values + pre ) , alpha = alpha [ count ] ) #NEWLINE# #UNINDENT# #UNINDENT# plt . plot ( plot_index , plot_values ) #NEWLINE# plt . title ( ( 'Forecast for ' + self . data_name ) ) #NEWLINE# plt . xlabel ( 'Time' ) #NEWLINE# plt . ylabel ( self . data_name ) #NEWLINE# plt . show ( ) #NEWLINE# self . predictions = { #NEWLINE# #INDENT# 'error_bars' : error_bars , #NEWLINE# 'forecasted_values' : forecasted_values , #NEWLINE# 'plot_values' : plot_values , #NEWLINE# 'plot_index' : plot_index , #NEWLINE# #UNINDENT# }