{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\n%matplotlib inline\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# Let's get top 10 most checked-in place ids:\ntrain = pd.read_csv(\"../input/train.csv\")\nprint(train.place_id.value_counts().nlargest(10))\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# Now, let's look at the accuracy distribution\nplace_data = train[train.place_id==8772469670]\nprint(place_data.accuracy.min(),place_data.accuracy.max())\nplace_data.accuracy.plot(kind='hist',title='accuracy distribution',bins=100)\n\n\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "place_data.accuracy.plot(kind='hist',title='deeper look',xlim=(0,100),bins=100)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "def category(acc):\n    if acc <= 10:\n        return '0-10'\n    elif acc <= 20:\n        return '10-20'\n    elif acc <= 30:\n        return '20-30'\n    elif acc <= 40:\n        return '30-40'\n    elif acc <= 50:\n        return '40-50'\n    elif acc <= 60:\n        return '50-60'\n    elif acc <= 70:\n        return '60-70'\n    elif acc <= 80:\n        return '70-80'\n    elif acc <= 90:\n        return '80-90'\n    else:\n        return '90-1000'\n    \npd.options.mode.chained_assignment=None\nplace_data['accuracy_cat'] = place_data.accuracy.map(lambda x: category(x))\n\n# plot standard deviation vs. accuracy category\nprint(place_data.groupby('accuracy_cat').count()[['x','y']])\nprint(place_data.groupby('accuracy_cat').std()[['x','y']])\n\n\n\n\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# Now, let's look at the accuracy distribution\nprint(place_data.accuracy.min(),place_data.accuracy.max())\nplace_data.accuracy.plot(kind='hist',title='accuracy distribution',bins=100)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "place_data.accuracy.plot(kind='hist',title='deeper look',xlim=(0,100),bins=100)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "def category(acc):\n    if acc <= 10:\n        return '0-10'\n    elif acc <= 20:\n        return '10-20'\n    elif acc <= 30:\n        return '20-30'\n    elif acc <= 40:\n        return '30-40'\n    elif acc <= 50:\n        return '40-50'\n    elif acc <= 60:\n        return '50-60'\n    elif acc <= 70:\n        return '60-70'\n    elif acc <= 80:\n        return '70-80'\n    elif acc <= 90:\n        return '80-90'\n    else:\n        return '90-1000'\n    \npd.options.mode.chained_assignment=None\nplace_data['accuracy_cat'] = place_data.accuracy.map(lambda x: category(x))\n\n# plot standard deviation vs. accuracy category\nprint(place_data.groupby('accuracy_cat').count()[['x','y']])\nprint(place_data.groupby('accuracy_cat').std()[['x','y']])"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# Now, let's look at the accuracy distribution\nplace_data = train[train.place_id==1308450003]\nprint(place_data.accuracy.min(),place_data.accuracy.max())\nplace_data.accuracy.plot(kind='hist',title='accuracy distribution',bins=100)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "place_data.accuracy.plot(kind='hist',title='deeper look',xlim=(0,100),bins=100)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "def category(acc):\n    if acc <= 10:\n        return '0-10'\n    elif acc <= 20:\n        return '10-20'\n    elif acc <= 30:\n        return '20-30'\n    elif acc <= 40:\n        return '30-40'\n    elif acc <= 50:\n        return '40-50'\n    elif acc <= 60:\n        return '50-60'\n    elif acc <= 70:\n        return '60-70'\n    elif acc <= 80:\n        return '70-80'\n    elif acc <= 90:\n        return '80-90'\n    else:\n        return '90-1000'\n    \npd.options.mode.chained_assignment=None\nplace_data['accuracy_cat'] = place_data.accuracy.map(lambda x: category(x))\n\n# plot standard deviation vs. accuracy category\nprint(place_data.groupby('accuracy_cat').count()[['x','y']])\nprint(place_data.groupby('accuracy_cat').std()[['x','y']])"
 },
 {
  "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}