{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Scalers\n\n\nThis example shows the different scaling algorithms available in\n:mod:`pyts.preprocessing`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\nfrom pyts.preprocessing import (StandardScaler, MinMaxScaler,\n                                MaxAbsScaler, RobustScaler)\n\n# Parameters\nn_samples, n_timestamps = 100, 48\nmarker_size = 5\n\n# Toy dataset\nrng = np.random.RandomState(41)\nX = rng.randn(n_samples, n_timestamps)\n\n# Scale the data with different scaling algorithms\nX_standard = StandardScaler().transform(X)\nX_minmax = MinMaxScaler(sample_range=(0, 1)).transform(X)\nX_maxabs = MaxAbsScaler().transform(X)\nX_robust = RobustScaler(quantile_range=(25.0, 75.0)).transform(X)\n\n# Show the results for the first time series\nplt.figure(figsize=(16, 6))\n\nax1 = plt.subplot(121)\nax1.plot(X[0], 'o-', ms=marker_size, label='Original')\nax1.set_title('Original time series', fontsize=16)\nax1.legend(loc='best', fontsize=12)\n\nax2 = plt.subplot(122)\nax2.plot(X_standard[0], 'o--', ms=marker_size, color='C1',\n         label='StandardScaler')\nax2.plot(X_minmax[0], 'o--', ms=marker_size, color='C2', label='MinMaxScaler')\nax2.plot(X_maxabs[0], 'o--', ms=marker_size, color='C3', label='MaxAbsScaler')\nax2.plot(X_robust[0], 'o--', ms=marker_size, color='C4', label='RobustScaler')\nax2.set_title('Scaled time series', fontsize=16)\nax2.legend(loc='best', fontsize=12)\n\nplt.suptitle('Scaling time series with different strategies', fontsize=20)\nplt.tight_layout()\nplt.subplots_adjust(top=0.85)\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}