.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_preprocessing_plot_transformers.py: ============ Transformers ============ Some algorithms make assumptions on the distribution of the data. Therefore it can be useful to transform time series so that they approximatively follow a given distribution. Two transformers are made available: * :class:`pyts.preprocessing.PowerTransformer` * :class:`pyts.preprocessing.QuantileTransformer`. This example illustrates the transformation from both algorithms. .. image:: /auto_examples/preprocessing/images/sphx_glr_plot_transformers_001.png :class: sphx-glr-single-img .. code-block:: default # Author: Johann Faouzi # License: BSD-3-Clause import matplotlib.pyplot as plt from pyts.datasets import load_gunpoint from pyts.preprocessing import PowerTransformer, QuantileTransformer X, _, _, _ = load_gunpoint(return_X_y=True) n_timestamps = X.shape[1] # Transform the data with different transformation algorithms X_power = PowerTransformer().transform(X) X_quantile = QuantileTransformer(n_quantiles=n_timestamps).transform(X) # Show the results for the first time series plt.figure(figsize=(6, 4)) plt.plot(X[0], '--', label='Original') plt.plot(X_power[0], '--', label='PowerTransformer') plt.plot(X_quantile[0], '--', label='QuantileTransformer') plt.legend(loc='best', fontsize=8) plt.title('Transforming time series', fontsize=16) plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.379 seconds) .. _sphx_glr_download_auto_examples_preprocessing_plot_transformers.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_transformers.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_transformers.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_