{"nbformat": 4, "metadata": {"kernelspec": {"name": "python3", "display_name": "Python 3", "language": "python"}, "language_info": {"version": "3.6.3", "pygments_lexer": "ipython3", "mimetype": "text/x-python", "nbconvert_exporter": "python", "name": "python", "file_extension": ".py", "codemirror_mode": {"name": "ipython", "version": 3}}}, "nbformat_minor": 1, "cells": [{"cell_type": "code", "metadata": {"_cell_guid": "18719494-3e65-461d-9747-78257e3ca673", "_uuid": "41d021b144226c8aaea236872a9b15a91750e30b", "collapsed": true}, "outputs": [], "source": ["import numpy as np\n", "import pandas as pd\n", "\n", "from subprocess import check_output\n", "print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))"], "execution_count": null}, {"cell_type": "code", "metadata": {"_cell_guid": "e68e5074-efeb-40af-af6b-a884314161c7", "_uuid": "5a3b4797953077ad6d4fea88042e24b317decea9", "collapsed": true}, "outputs": [], "source": ["ets_forecasts = pd.read_csv('../input/ensemble-grocery-01/sub_ets_log.csv', index_col=0)\n", "test = pd.read_csv('../input/favorita-grocery-sales-forecasting/test.csv', \n", "                   parse_dates=['date'], index_col=0)"], "execution_count": null}, {"cell_type": "code", "metadata": {"_cell_guid": "3a6656ac-20d5-42db-bf4a-c065ee7e083d", "_uuid": "af89c54d8804b0b839aabd5a47ee5eec229f772f", "collapsed": true}, "outputs": [], "source": ["ets_forecasts.head()"], "execution_count": null}, {"cell_type": "code", "metadata": {"_cell_guid": "3e12ff89-3755-4d23-94ae-e67286cd6f71", "_uuid": "2eacc13974f9c10d5135d3b6f8afda47e8f8367f", "collapsed": true}, "outputs": [], "source": ["test.head()"], "execution_count": null}, {"cell_type": "code", "metadata": {"_cell_guid": "05af9330-98b9-4b0d-863a-a096aad48907", "_uuid": "a36c8586efd0a0af53ffee686e895f41fffbe010", "collapsed": true}, "outputs": [], "source": ["results = test[['date']].join(ets_forecasts).sort_values('unit_sales',ascending=False)"], "execution_count": null}, {"cell_type": "code", "metadata": {"_cell_guid": "abc3f359-288e-4dbe-9a2a-bb0258ca376b", "_uuid": "e43b18dba6bf4d6f2e908da013e6af1824207420", "collapsed": true}, "outputs": [], "source": ["results.head(20)"], "execution_count": null}, {"cell_type": "markdown", "metadata": {"_cell_guid": "e148e7a1-5ed8-442e-82f6-54b2bd42740f", "_uuid": "3d50c6604275562cf86bbe013f0b73343ed28415"}, "source": ["Look at the first row above.  It predicts that some store sold nearly 2 billion units of some item on August 31.  Without bothering to look up which store or which item, I'm pretty confident taking the \"under\" on that one.\n", "\n", "I would guess that at least the first 10 of the entries above, if not all 20, and possibly a lot more down the list that aren't shown, are going to come in with quite large errors.  But the submission file from which I took these entries earned a very respectable public leaderboard score of 0.556.  As of this writing, if you sort by best score, [the kernel that produced it](https://www.kaggle.com/dongxu027/time-series-ets-starter-lb-0-556) comes in 9th among public kernels,  (And in a sense it really comes in 3rd, becuase all the ones above it represent variations on, and/or ensembles of, just two basic approaches.)\n", "\n", "Notice that all the dates above are closer to the end of the test period, and recall that the test data are split on time.  (Moreover, tarobxl [has demonstrated](https://www.kaggle.com/tarobxl/how-the-test-set-is-split-lb-0-532) exactly how it is split, and none of the dates above are part of the public test data.)\n", "\n", "There are problems with using standard time series methods to project more than a few periods into the future.  Sometimes those forecasts can be useful, but in general they need to be approached with a healthy skepticism.  It can be quite dangerous if you're getting feedback only from near-future results but being evaluated only on far-future results."]}, {"cell_type": "code", "metadata": {"_cell_guid": "85a59549-0751-4bee-ab64-3a12773ba358", "_uuid": "63b9f16078f4fe2b7d8a3fec9ce373707c2a7505", "collapsed": true}, "outputs": [], "source": [], "execution_count": null}]}