{"cells":[
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "# Facebook V: Predicting Check Ins \n# Exploratory Data Analysis\n\n## 1 - Setup\n### 1.1 - Import Packages"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%pylab inline"
 },
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "### 1.2 - Load Data\n\n#### VARIABLE DESCRIPTIONS:\n* **row_id:** id of the check-in event\n* **x y:** coordinates\n* **accuracy:** location accuracy \n* **time:** timestamp\n* **place_id:** id of the business, this is the target you are predicting"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train_data = pd.read_csv('../input/train.csv',dtype={'place_id':'int64'})\ntest_data = pd.read_csv('../input/test.csv',dtype={'place_id':'int64'})\nfull_data = pd.concat([train_data, test_data]).reset_index(drop=True)\nprint ('Train Set Shape:',train_data.shape)\nprint ('Test Set Shape:',test_data.shape)\nfull_data.tail()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "full_data.describe()"
 },
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "## 2 - Timestamp\n\nSimply looking at the KDE distribution of time does not provide much information. The only thing to notice are two valleys that probably indicate some kind of seasonality. "
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "sns.distplot(full_data.time.sample(frac=0.01))"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "ts_count = full_data.time.value_counts().sort_index()\nts_fft = np.fft.fft(ts_count.tolist())\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "p = plt.plot(ts_fft)\nplt.xlim([0,2000])\n#plt.ylim([0,1e6])"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": ""
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}