.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/preprocessing/plot_transformers.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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. .. GENERATED FROM PYTHON SOURCE LINES 16-40 .. image-sg:: /auto_examples/preprocessing/images/sphx_glr_plot_transformers_001.png :alt: Non-linear transformations :srcset: /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('Non-linear transformations', fontsize=16) plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.338 seconds) .. _sphx_glr_download_auto_examples_preprocessing_plot_transformers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_transformers.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_transformers.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_