In [1]:
import numpy as np
import pandas as pd
%matplotlib inline
In [2]:
df_train = pd.read_csv("https://raw.githubusercontent.com/antoinecarme/TimeSeriesData/master/R_TSData/taylor.csv")
import pyaf.ForecastEngine as autof
lEngine = autof.cForecastEngine()
lEngine.train(iInputDS = df_train, iTime = 'time', iSignal = 'signal', iHorizon = 36);
lEngine.getModelInfo() #
INFO:pyaf.std:START_TRAINING 'signal'
INFO:pyaf.std:END_TRAINING_TIME_IN_SECONDS 'signal' 4.972797632217407
INFO:pyaf.std:TIME_DETAIL TimeVariable='time' TimeMin=1.0 TimeMax=10.5089285714 TimeDelta=0.00297619047619 Estimation = (0 , 3196) Validation = (3196 , 3996) Test = (3996 , 4032) Horizon=36
INFO:pyaf.std:SIGNAL_DETAIL SignalVariable='_signal' Min=18640 Max=38777 Mean=29617.1361607 StdDev=5566.66934654
INFO:pyaf.std:BEST_TRANSOFORMATION_TYPE '_'
INFO:pyaf.std:BEST_DECOMPOSITION '_signal_ConstantTrend_residue_zeroCycle_residue_AR(64)' [ConstantTrend + NoCycle + AR(64)]
INFO:pyaf.std:TREND_DETAIL '_signal_ConstantTrend' [ConstantTrend]
INFO:pyaf.std:CYCLE_DETAIL '_signal_ConstantTrend_residue_zeroCycle' [NoCycle]
INFO:pyaf.std:AUTOREG_DETAIL '_signal_ConstantTrend_residue_zeroCycle_residue_AR(64)' [AR(64)]
INFO:pyaf.std:MODEL_MAPE MAPE_Fit=0.0062 MAPE_Forecast=0.0059 MAPE_Test=0.007
INFO:pyaf.std:MODEL_SMAPE SMAPE_Fit=0.0062 SMAPE_Forecast=0.0059 SMAPE_Test=0.007
INFO:pyaf.std:MODEL_MASE MASE_Fit=0.274 MASE_Forecast=0.2618 MASE_Test=0.3054
INFO:pyaf.std:MODEL_L1 L1_Fit=248.806530285 L1_Forecast=235.914255312 L1_Test=181.839427682
INFO:pyaf.std:MODEL_L2 L2_Fit=248.806530285 L2_Forecast=235.914255312 L2_Test=260.87454011
INFO:pyaf.std:MODEL_COMPLEXITY 64
INFO:pyaf.std:AR_MODEL_DETAIL_START
INFO:pyaf.std:AR_MODEL_COEFF 1 _signal_ConstantTrend_residue_zeroCycle_residue_Lag1 1.68274914575
INFO:pyaf.std:AR_MODEL_COEFF 2 _signal_ConstantTrend_residue_zeroCycle_residue_Lag49 -0.915876219495
INFO:pyaf.std:AR_MODEL_COEFF 3 _signal_ConstantTrend_residue_zeroCycle_residue_Lag2 -0.509562735422
INFO:pyaf.std:AR_MODEL_COEFF 4 _signal_ConstantTrend_residue_zeroCycle_residue_Lag48 0.438228289731
INFO:pyaf.std:AR_MODEL_COEFF 5 _signal_ConstantTrend_residue_zeroCycle_residue_Lag3 -0.406221741754
INFO:pyaf.std:AR_MODEL_COEFF 6 _signal_ConstantTrend_residue_zeroCycle_residue_Lag4 0.270083145596
INFO:pyaf.std:AR_MODEL_COEFF 7 _signal_ConstantTrend_residue_zeroCycle_residue_Lag51 0.234702660669
INFO:pyaf.std:AR_MODEL_COEFF 8 _signal_ConstantTrend_residue_zeroCycle_residue_Lag50 0.211164756842
INFO:pyaf.std:AR_MODEL_COEFF 9 _signal_ConstantTrend_residue_zeroCycle_residue_Lag46 0.148150473567
INFO:pyaf.std:AR_MODEL_COEFF 10 _signal_ConstantTrend_residue_zeroCycle_residue_Lag14 -0.116298490773
INFO:pyaf.std:AR_MODEL_DETAIL_END
In [3]:
lEngine.standrdPlots()
INFO:pyaf.std:START_PLOTTING
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:30: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:107: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
INFO:pyaf.std:END_PLOTTING_TIME_IN_SECONDS 4.188075065612793
In [4]:
lEngine2 = autof.cForecastEngine()
lEngine2.mOptions.set_active_autoregressions([])
lEngine2.mOptions.mCycleLengths = range(2,500);
lEngine2.train(iInputDS = df_train, iTime = 'time', iSignal = 'signal', iHorizon = 36);
lEngine2.getModelInfo() # => relative error 7% (MAPE)
INFO:pyaf.std:START_TRAINING 'signal'
INFO:pyaf.std:END_TRAINING_TIME_IN_SECONDS 'signal' 32.50502920150757
INFO:pyaf.std:TIME_DETAIL TimeVariable='time' TimeMin=1.0 TimeMax=10.5089285714 TimeDelta=0.00297619047619 Estimation = (0 , 3196) Validation = (3196 , 3996) Test = (3996 , 4032) Horizon=36
INFO:pyaf.std:SIGNAL_DETAIL SignalVariable='_signal' Min=18640 Max=38777 Mean=29617.1361607 StdDev=5566.66934654
INFO:pyaf.std:BEST_TRANSOFORMATION_TYPE '_'
INFO:pyaf.std:BEST_DECOMPOSITION '_signal_ConstantTrend_residue_bestCycle_byL2_residue_NoAR' [ConstantTrend + Cycle_Length_336 + NoAR]
INFO:pyaf.std:TREND_DETAIL '_signal_ConstantTrend' [ConstantTrend]
INFO:pyaf.std:CYCLE_DETAIL '_signal_ConstantTrend_residue_bestCycle_byL2' [Cycle_Length_336]
INFO:pyaf.std:AUTOREG_DETAIL '_signal_ConstantTrend_residue_bestCycle_byL2_residue_NoAR' [NoAR]
INFO:pyaf.std:MODEL_MAPE MAPE_Fit=0.0218 MAPE_Forecast=0.0167 MAPE_Test=0.0194
INFO:pyaf.std:MODEL_SMAPE SMAPE_Fit=0.0217 SMAPE_Forecast=0.0169 SMAPE_Test=0.0193
INFO:pyaf.std:MODEL_MASE MASE_Fit=0.9782 MASE_Forecast=0.7662 MASE_Test=0.8761
INFO:pyaf.std:MODEL_L1 L1_Fit=806.570139275 L1_Forecast=760.807107121 L1_Test=521.697530864
INFO:pyaf.std:MODEL_L2 L2_Fit=806.570139275 L2_Forecast=760.807107121 L2_Test=618.915242584
INFO:pyaf.std:MODEL_COMPLEXITY 8
INFO:pyaf.std:AR_MODEL_DETAIL_START
INFO:pyaf.std:AR_MODEL_DETAIL_END
In [5]:
lEngine2.standrdPlots()
INFO:pyaf.std:START_PLOTTING
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:30: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:107: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
INFO:pyaf.std:END_PLOTTING_TIME_IN_SECONDS 2.1498355865478516
In [6]:
lEngine3 = autof.cForecastEngine()
lEngine3.mOptions.mCycleLengths = range(2,500);
lEngine3.train(iInputDS = df_train, iTime = 'time', iSignal = 'signal', iHorizon = 36);
lEngine3.getModelInfo() # => relative error 7% (MAPE)
INFO:pyaf.std:START_TRAINING 'signal'
INFO:pyaf.std:END_TRAINING_TIME_IN_SECONDS 'signal' 33.65408802032471
INFO:pyaf.std:TIME_DETAIL TimeVariable='time' TimeMin=1.0 TimeMax=10.5089285714 TimeDelta=0.00297619047619 Estimation = (0 , 3196) Validation = (3196 , 3996) Test = (3996 , 4032) Horizon=36
INFO:pyaf.std:SIGNAL_DETAIL SignalVariable='_signal' Min=18640 Max=38777 Mean=29617.1361607 StdDev=5566.66934654
INFO:pyaf.std:BEST_TRANSOFORMATION_TYPE '_'
INFO:pyaf.std:BEST_DECOMPOSITION '_signal_Lag1Trend_residue_bestCycle_byL2_residue_NoAR' [Lag1Trend + Cycle_Length_336 + NoAR]
INFO:pyaf.std:TREND_DETAIL '_signal_Lag1Trend' [Lag1Trend]
INFO:pyaf.std:CYCLE_DETAIL '_signal_Lag1Trend_residue_bestCycle_byL2' [Cycle_Length_336]
INFO:pyaf.std:AUTOREG_DETAIL '_signal_Lag1Trend_residue_bestCycle_byL2_residue_NoAR' [NoAR]
INFO:pyaf.std:MODEL_MAPE MAPE_Fit=0.004 MAPE_Forecast=0.0073 MAPE_Test=0.0094
INFO:pyaf.std:MODEL_SMAPE SMAPE_Fit=0.004 SMAPE_Forecast=0.0073 SMAPE_Test=0.0094
INFO:pyaf.std:MODEL_MASE MASE_Fit=0.1767 MASE_Forecast=0.3347 MASE_Test=0.4187
INFO:pyaf.std:MODEL_L1 L1_Fit=172.357801568 L1_Forecast=361.830004016 L1_Test=249.327160494
INFO:pyaf.std:MODEL_L2 L2_Fit=172.357801568 L2_Forecast=361.830004016 L2_Test=409.235786992
INFO:pyaf.std:MODEL_COMPLEXITY 40
INFO:pyaf.std:AR_MODEL_DETAIL_START
INFO:pyaf.std:AR_MODEL_DETAIL_END
In [7]:
lEngine3.standrdPlots()
INFO:pyaf.std:START_PLOTTING
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:30: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
/home/antoine/dev/python/packages/pyaf/TS/Plots.py:107: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/home/antoine/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/antoine/.local/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/antoine/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-746e0005dc42>", line 4, in <module>
get_ipython().magic('matplotlib inline')
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2158, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2079, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-104>", line 2, in matplotlib
File "/usr/lib/python3/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py", line 100, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2947, in enable_matplotlib
pt.activate_matplotlib(backend)
File "/usr/lib/python3/dist-packages/IPython/core/pylabtools.py", line 295, in activate_matplotlib
matplotlib.pyplot.switch_backend(backend)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 229, in switch_backend
matplotlib.use(newbackend, warn=False, force=True)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1305, in use
reload(sys.modules['matplotlib.backends'])
File "/usr/lib/python3.6/importlib/__init__.py", line 166, in reload
_bootstrap._exec(spec, module)
File "/home/antoine/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
matplotlib.use('Agg')
INFO:pyaf.std:END_PLOTTING_TIME_IN_SECONDS 2.286111354827881
In [ ]:
Content source: antoinecarme/pyaf
Similar notebooks: