In [2]:
import pandas as pd
import numpy as np
import pyaf.ForecastEngine as autof
import pyaf.Bench.TS_datasets as tsds
import pyaf.Bench.MComp as mcomp
import mpld3
mpld3.enable_notebook()
%matplotlib inline
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:98: DeprecationWarning: DisplayFormatter._formatters_default is deprecated: use @default decorator instead.
def _formatters_default(self):
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:677: DeprecationWarning: PlainTextFormatter._deferred_printers_default is deprecated: use @default decorator instead.
def _deferred_printers_default(self):
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:669: DeprecationWarning: PlainTextFormatter._singleton_printers_default is deprecated: use @default decorator instead.
def _singleton_printers_default(self):
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:672: DeprecationWarning: PlainTextFormatter._type_printers_default is deprecated: use @default decorator instead.
def _type_printers_default(self):
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:66: DeprecationWarning: metadata {'config': True} was set from the constructor. Metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
inline backend."""
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:71: DeprecationWarning: metadata {'config': True} was set from the constructor. Metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
'retina', 'jpeg', 'svg', 'pdf'.""")
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:85: DeprecationWarning: metadata {'config': True} was set from the constructor. Metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
use `figure_formats` instead)""")
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:95: DeprecationWarning: metadata {'config': True} was set from the constructor. Metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
"""
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:114: DeprecationWarning: metadata {'config': True} was set from the constructor. Metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
""")
/usr/local/lib/python3.5/dist-packages/ipykernel/pylab/config.py:44: DeprecationWarning: InlineBackend._config_changed is deprecated: use @observe and @unobserve instead.
def _config_changed(self, name, old, new):
/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py:770: DeprecationWarning: A parent of InlineBackend._config_changed has adopted the new @observe(change) API
clsname, change_or_name), DeprecationWarning)
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:672: DeprecationWarning: PlainTextFormatter._type_printers_default is deprecated: use @default decorator instead.
def _type_printers_default(self):
/usr/local/lib/python3.5/dist-packages/IPython/core/formatters.py:677: DeprecationWarning: PlainTextFormatter._deferred_printers_default is deprecated: use @default decorator instead.
def _deferred_printers_default(self):
In [4]:
tester1 = mcomp.cMComp_Tester(tsds.load_M4_comp() , "M4_COMP");
tester1.testSignals('MNI21 YAD5')
---------------------------------------------------------------------------
Error Traceback (most recent call last)
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _next_line(self)
2346 try:
-> 2347 orig_line = next(self.data)
2348 except csv.Error as e:
Error: line contains NULL byte
During handling of the above exception, another exception occurred:
Error Traceback (most recent call last)
<ipython-input-4-b08177921da1> in <module>()
----> 1 tester1 = mcomp.cMComp_Tester(tsds.load_M4_comp() , "M4_COMP");
2 tester1.testSignals('MNI21 YAD5')
/home/antoine/dev/python/packages/pyaf/Bench/TS_datasets.py in load_M4_comp()
565 trainfile = "https://raw.githubusercontent.com/antoinecarme/pyaf/master/data/M4Comp.csv.gz"
566
--> 567 df_full = pd.read_csv(trainfile, sep=',', header=0, engine='python');
568 lHorizons = df_full[['H' , 'ID']].copy();
569 lHorizons['ID'] = lHorizons['ID'].apply(lambda x : x.replace(" ", ""));
/usr/lib/python3/dist-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
644 skip_blank_lines=skip_blank_lines)
645
--> 646 return _read(filepath_or_buffer, kwds)
647
648 parser_f.__name__ = name
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
387
388 # Create the parser.
--> 389 parser = TextFileReader(filepath_or_buffer, **kwds)
390
391 if (nrows is not None) and (chunksize is not None):
/usr/lib/python3/dist-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
728 self.options['has_index_names'] = kwds['has_index_names']
729
--> 730 self._make_engine(self.engine)
731
732 def close(self):
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _make_engine(self, engine)
927 elif engine == 'python-fwf':
928 klass = FixedWidthFieldParser
--> 929 self._engine = klass(self.f, **self.options)
930
931 def _failover_to_python(self):
/usr/lib/python3/dist-packages/pandas/io/parsers.py in __init__(self, f, **kwds)
1818 # infer column indices from self.usecols if is is specified.
1819 self._col_indices = None
-> 1820 self.columns, self.num_original_columns = self._infer_columns()
1821
1822 # Now self.columns has the set of columns that we will process.
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _infer_columns(self)
2094 for level, hr in enumerate(header):
2095 try:
-> 2096 line = self._buffered_line()
2097
2098 while self.line_pos <= hr:
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _buffered_line(self)
2252 return self.buf[0]
2253 else:
-> 2254 return self._next_line()
2255
2256 def _check_for_bom(self, first_row):
/usr/lib/python3/dist-packages/pandas/io/parsers.py in _next_line(self)
2363 msg += '. ' + reason
2364
-> 2365 raise csv.Error(msg)
2366 line = self._check_comments([orig_line])[0]
2367 self.pos += 1
Error: NULL byte detected. This byte cannot be processed in Python's native csv library at the moment, so please pass in engine='c' instead
In [ ]:
tester1.mBunch.mHorizons.head()
In [ ]:
tester1.mBunch.mHorizons.info()
In [ ]:
tester1.mFull_DF.info()
In [ ]:
tester1.mFull_DF.head()
In [ ]:
sig = 'FIN98'
%prun tester1.testSignal(sig)
In [ ]:
lDecomp = tester1.mDecompBySignal[sig]
lDecomp
In [ ]:
tester1.mApplyOut.plot('Date' , [sig , sig + '_BestModelForecast'], figsize=[8, 8])
In [ ]:
tester1.mApplyOut.head()
In [ ]:
Content source: antoinecarme/pyaf
Similar notebooks: