.. _sphx_glr_auto_examples_utils_example_tsdisplay.py:
====================================
Displaying key timeseries statistics
====================================
Visualizing characteristics of a time series is a key component to effective
forecasting. In this example, we'll look at a very simple method to examine
critical statistics of a time series object.
.. raw:: html
.. rst-class:: sphx-glr-horizontal
*
.. image:: /auto_examples/utils/images/sphx_glr_example_tsdisplay_001.png
:scale: 47
*
.. image:: /auto_examples/utils/images/sphx_glr_example_tsdisplay_002.png
:scale: 47
.. rst-class:: sphx-glr-script-out
Out::
Data shape: 2820
Data head:
Jan 1749 58.0
Feb 1749 62.6
Mar 1749 70.0
Apr 1749 55.7
May 1749 85.0
dtype: float64
As evidenced by the more normally distributed values in the transformed series,
using a Box-Cox transformation may prove useful prior to fitting your model.
|
.. code-block:: python
print(__doc__)
# Author: Taylor Smith
import pmdarima as pm
from pmdarima import datasets
from pmdarima import preprocessing
# We'll use the sunspots dataset for this example
y = datasets.load_sunspots(True)
print("Data shape: {}".format(y.shape[0]))
print("Data head:")
print(y.head())
# Let's look at the series, its ACF plot, and a histogram of its values
pm.tsdisplay(y, lag_max=90, title="Sunspots", show=True)
# Notice that the histogram is very skewed. This is a prime candidate for
# box-cox transformation
y_bc, _ = preprocessing.BoxCoxEndogTransformer(lmbda2=1e-6).fit_transform(y)
pm.tsdisplay(
y_bc, lag_max=90, title="Sunspots (BoxCox-transformed)", show=True)
print("""
As evidenced by the more normally distributed values in the transformed series,
using a Box-Cox transformation may prove useful prior to fitting your model.
""")
**Total running time of the script:** ( 0 minutes 0.275 seconds)
.. only :: html
.. container:: sphx-glr-footer
.. container:: sphx-glr-download
:download:`Download Python source code: example_tsdisplay.py `
.. container:: sphx-glr-download
:download:`Download Jupyter notebook: example_tsdisplay.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_