{"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)\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\n#print(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": "train1 = pd.read_csv(\"../input/train.csv\", parse_dates=['date_time'], nrows=1000)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import matplotlib.pyplot as plt"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "from matplotlib import cm"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train1[\"srch_ci\"] = pd.to_datetime(train1[\"srch_ci\"], format='%Y-%m-%d', errors=\"coerce\")\ntrain1[\"srch_co\"] = pd.to_datetime(train1[\"srch_co\"], format='%Y-%m-%d', errors=\"coerce\")\ntrain1[\"stay_span\"] = (train1[\"srch_co\"] - train1[\"srch_ci\"]).astype('timedelta64[D]')"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train1['individuals']=train1['srch_adults_cnt'] + train1['srch_children_cnt']"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train1."
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train = train1[['individuals','stay_span','hotel_country']]"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.axes_grid1 import make_axes_locatable"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "x = np.array(train1['hotel_cluster'])"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "y = np.array(train1['orig_destination_distance'])"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "fig, axScatter = plt.subplots(figsize=(5.5, 5.5))\n\n# the scatter plot:\naxScatter.scatter(x, y)\naxScatter.set_aspect(.1111)\ndivider = make_axes_locatable(axScatter)\naxHistx = divider.append_axes(\"top\", 1.2, pad=0.1, sharex=axScatter)\naxHisty = divider.append_axes(\"right\", 1.2, pad=0.1, sharey=axScatter)\nplt.setp(axHistx.get_xticklabels() + axHisty.get_yticklabels(), visible=False)\n\n# now determine nice limits by hand:\nbinwidth = 0.25\nxymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])\nlim = (int(xymax/binwidth) + 1)*binwidth"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "\n\n\n# create new axes on the right and on the top of the current axes\n# The first argument of the new_vertical(new_horizontal) method is\n# the height (width) of the axes to be created in inches.\n\n\n# make some labels invisible\n\n\nbins = np.arange(-lim, lim + binwidth, binwidth)\naxHistx.hist(x, bins=bins)\naxHisty.hist(y, bins=bins, orientation='horizontal')\n\n# the xaxis of axHistx and yaxis of axHisty are shared with axScatter,\n# thus there is no need to manually adjust the xlim and ylim of these\n# axis.\n\n#axHistx.axis[\"bottom\"].major_ticklabels.set_visible(False)\nfor tl in axHistx.get_xticklabels():\n    tl.set_visible(False)\naxHistx.set_yticks([0, 50, 100])\n\n#axHisty.axis[\"left\"].major_ticklabels.set_visible(False)\nfor tl in axHisty.get_yticklabels():\n    tl.set_visible(False)\naxHisty.set_xticks([0, 50, 100])\n\nplt.draw()\nplt.show()"
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}