diff --git a/Gluonts_twitter_volume_forecasting.ipynb b/Gluonts_twitter_volume_forecasting.ipynb index 44fff5e..7fce52e 100644 --- a/Gluonts_twitter_volume_forecasting.ipynb +++ b/Gluonts_twitter_volume_forecasting.ipynb @@ -5,7 +5,7 @@ "colab": { "name": "Gluonts twitter volume forecasting.ipynb", "provenance": [], - "authorship_tag": "ABX9TyPAYWXhyZ3fbVnl/1L+Mwyg", + "authorship_tag": "ABX9TyPnECKy9/9x3uizOlZK+rEl", "include_colab_link": true }, "kernelspec": { @@ -119,45 +119,144 @@ { "cell_type": "code", "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 552 - }, - "id": "vVNMTd-BEWHG", - "outputId": "e51662c7-2b14-4a14-e944-34a69d5a9f7f" + "id": "vVNMTd-BEWHG" }, "source": [ "from gluonts.dataset import common\r\n", "from gluonts.model import deepar\r\n", "from gluonts.trainer import Trainer\r\n", "\r\n", - "import pandas as pd\r\n", - "\r\n", + "import pandas as pd" + ], + "execution_count": 6, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 235 + }, + "id": "zp2hdhzlFhlg", + "outputId": "49cc7e56-9c58-4798-9e5a-d71c1c56b05a" + }, + "source": [ "url = \"https://raw.githubusercontent.com/numenta/NAB/master/data/realTweets/Twitter_volume_AMZN.csv\"\r\n", "df = pd.read_csv(url, header=0, index_col=0)\r\n", + "df.head()" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
value
timestamp
2015-02-26 21:42:5357
2015-02-26 21:47:5343
2015-02-26 21:52:5355
2015-02-26 21:57:5364
2015-02-26 22:02:5393
\n", + "
" + ], + "text/plain": [ + " value\n", + "timestamp \n", + "2015-02-26 21:42:53 57\n", + "2015-02-26 21:47:53 43\n", + "2015-02-26 21:52:53 55\n", + "2015-02-26 21:57:53 64\n", + "2015-02-26 22:02:53 93" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 7 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "AAMItQe-FmmX" + }, + "source": [ "data = common.ListDataset([{\r\n", " \"start\": df.index[0],\r\n", " \"target\": df.value[:\"2015-04-05 00:00:00\"]\r\n", "}],\r\n", - " freq=\"5min\")\r\n", - "\r\n", + " freq=\"5min\")\r\n" + ], + "execution_count": 8, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Gqxl1PoDFpjh", + "outputId": "fddc6dcf-d859-48a2-a561-cc3f546a6685" + }, + "source": [ "trainer = Trainer(epochs=10)\r\n", "estimator = deepar.DeepAREstimator(\r\n", " freq=\"5min\", prediction_length=12, trainer=trainer)\r\n", "predictor = estimator.train(training_data=data)\r\n", "\r\n", - "prediction = next(predictor.predict(data))\r\n", - "print(prediction.mean)\r\n", - "prediction.plot(output_file='graph.png')\r\n" + "prediction = next(predictor.predict(data))" ], - "execution_count": 4, + "execution_count": 9, "outputs": [ { "output_type": "stream", "text": [ - "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:3: DeprecationWarning: gluonts.trainer is deprecated. Use gluonts.mx.trainer instead.\n", - " This is separate from the ipykernel package so we can avoid doing imports until\n", - " 0%| | 0/50 [00:00" ] @@ -210,7 +357,7 @@ { "cell_type": "code", "metadata": { - "id": "E27gbMFrEh0E" + "id": "OBEvWiyjFRgK" }, "source": [ ""