{"nbformat": 4, "cells": [{"execution_count": null, "cell_type": "markdown", "outputs": [], "source": "z\n", "metadata": {"_execution_state": "idle", "_uuid": "35928f2f72372e969f64daae4d476db9279f7de8", "_cell_guid": "5ac985bd-21e8-4302-89ce-3d2285f0d59e", "collapsed": false}}, {"execution_count": null, "cell_type": "code", "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 seaborn as sns\nimport matplotlib.pyplot as plt\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.", "metadata": {"_execution_state": "idle", "_uuid": "cfa28768851c4db363f269166dd0bf95cc7060fb", "_cell_guid": "c7a0e214-d71a-4690-9a6d-0f3a6397276d", "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# Get first 10000000 rows and print some info about columns\ntrain = pd.read_csv(\"../input/train.csv\", parse_dates=['srch_ci', 'srch_co'], nrows=10000000)\ntrain.info()", "metadata": {"_execution_state": "idle", "_uuid": "d04da01cffd967e34f0ab1aa8a82fbcba8fc3843", "_cell_guid": "a212aca8-4db5-4c92-bab2-6b350fa26ede", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "destinations = pd.read_csv(\"../input/destinations.csv\")\ntest = pd.read_csv(\"../input/test.csv\")", "metadata": {"_execution_state": "idle", "_uuid": "dfbaea3f8d0f41146274fa26d3702d3c9c8af963", "_cell_guid": "5091dcf7-6ca8-4ab3-93f8-052962224300", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "train[\"hotel_cluster\"].value_counts()", "metadata": {"_execution_state": "idle", "_uuid": "1cb611ea4e0d9ccee8e3598828acc6bc209effdf", "_cell_guid": "3f93efd0-eb90-43c6-a27f-eac64fff7a10", "collapsed": false, "trusted": false}}, {"execution_count": null, "outputs": [], "cell_type": "code", "source": "test_ids = set(test.user_id.unique())\ntrain_ids = set(train.user_id.unique())\nintersection_count = len(test_ids & train_ids)\nintersection_count == len(test_ids)\n#false : because it is no entire data", "metadata": {"_execution_state": "idle", "_uuid": "68b1f482bdd1ad79af79156ad0f4603287d2e75a", "_cell_guid": "844f129e-aaf1-45fe-80ef-1c21a977aeae", "collapsed": false, "trusted": false}}, {"execution_count": null, "outputs": [], "cell_type": "code", "source": "# preferred continent destinations\nsns.countplot(x='hotel_continent', data=train)", "metadata": {"_execution_state": "idle", "_uuid": "5782e911c1cdb265d925c52799ea67b31fcceeca", "_cell_guid": "cce92457-8464-419d-b93b-b0db4eabd15d", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# most of people booking are from continent 3 I guess is one of the rich continent?\nsns.countplot(x='posa_continent', data=train)\n", "metadata": {"_execution_state": "idle", "_uuid": "13d738063435aa1ae2e391a01c9bb32036a2710c", "_cell_guid": "3a4d93d5-005a-42a4-afcf-dcbf4e0eedda", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# putting the two above together\nsns.countplot(x='hotel_continent', hue='posa_continent', data=train)", "metadata": {"_execution_state": "idle", "_uuid": "c72321adcfe099ef1f8b4006f05c5d608eb76d4c", "_cell_guid": "a5c31762-069b-46bc-bac8-8ba3e48ebc99", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# how many people by continent are booking from mobile\nsns.countplot(x='posa_continent', hue='is_mobile', data = train)", "metadata": {"_execution_state": "idle", "_uuid": "3ed879018b7e0eb79cb82a641b6b38e855606c95", "_cell_guid": "817d0aca-e36c-460c-81c2-a30a0758a17d", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# Difference between user and destination country\nsns.distplot(train['user_location_country'], label=\"User country\")\nsns.distplot(train['hotel_country'], label=\"Hotel country\")\nplt.legend()", "metadata": {"_execution_state": "idle", "_uuid": "bd49aa63b18c318d1d79609e8badbf610a3f0990", "_cell_guid": "c76fd6d2-ca25-4948-8ccc-69fd34700092", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# distribution of the total number of people per cluster\nsrc_total_cnt = train.srch_adults_cnt + train.srch_children_cnt\ntrain['src_total_cnt'] = src_total_cnt\nax = sns.kdeplot(train['hotel_cluster'], train['src_total_cnt'], cmap=\"Purples_d\")\nlim = ax.set(ylim=(0.5, 4.5))", "metadata": {"_execution_state": "busy", "_uuid": "bf5e455655f7be9a5f1e86bbe36bccfbb48ff8e7", "_cell_guid": "5a224a90-b585-46da-8cce-222a20510f80", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "# plot all columns countplots\nrows = train.columns.size//3 - 1\nfig, axes = plt.subplots(nrows=rows, ncols=3, figsize=(12,18))\nfig.tight_layout()\ni = 0\nj = 0\nfor col in train.columns:\n    if j >= 3:\n        j = 0\n        i += 1\n    # avoid to plot by date    \n    if train[col].dtype == np.int64:\n        sns.countplot(x=col, data=train, ax=axes[i][j])\n        j += 1", "metadata": {"_execution_state": "busy", "_uuid": "3a684defe426d424a2223f2354b123eba696eb37", "_cell_guid": "838a9f94-8816-459d-b0f8-b5fd13c1fb8d", "collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "outputs": [], "source": "", "metadata": {"_execution_state": "busy", "_uuid": "d3722c44aa8f37437badc3d9b4f29207d4be9dff", "_cell_guid": "d42d2649-8994-4f3f-9be4-6021f9c41947", "collapsed": false, "trusted": false}}], "nbformat_minor": 0, "metadata": {"kernelspec": {"name": "python3", "display_name": "Python 3", "language": "python"}, "language_info": {"name": "python", "file_extension": ".py", "mimetype": "text/x-python", "codemirror_mode": {"name": "ipython", "version": 3}, "version": "3.6.1", "pygments_lexer": "ipython3", "nbconvert_exporter": "python"}}}