{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"train.csv has six columns:  user, event, invited, timestamp, interested, and not_interested.  Test.csv contains the same columns as train.csv, except for interested and not_interested. Each row corresponds to an event that was shown to a user in our application.  event is an id identifying an event in a our system.  user is an id representing a user in our system.  invited is a binary variable indicated whether the user has been invited to the event. timestamp is a ISO-8601 UTC time string representing the approximate time (+/- 2 hours) when the user saw the event in our application. interested is a binary variable indicating whether a user clicked on the \"Interested\" button for this event; it is 1 if the user clicked Interested and 0 if the user did not click the button.  Similarly, not_interested is a binary variable indicating whether a user clicked on the \"Not Interested\" button for this event; it is 1 if the user clicked the button and 0 if not.  It is possible that the user saw an event and clicked neither Interested nor Not Interested, and hence there are rows that contain 0,0 as values for interested,not_interested."},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/event-recommendation-engine-challenge/train.csv')\ntrain_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#check missing values\ntrain_df.isnull().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import numpy as np \nimport pandas as pd \n\nimport matplotlib.pyplot as plt\nimport seaborn as sns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# To\ntrain_df.event.unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Find no of users interested in each event\ntrain_df.event[train_df['interested']==1].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"chart = sns.countplot(train_df.event,\n              order=train_df.event.value_counts().iloc[:10].index)\nchart.set_xticklabels(chart.get_xticklabels(), rotation=90, horizontalalignment='right')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# No. of events\ntrain_df.event[train_df['invited']==1].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(10,8))\nplt.title('Barplot of Activity')\nsns.countplot(train_df.event)\nplt.xticks(rotation=90)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.heatmap(train_df.corr())","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Since all the correlation values are low, all the attributes need to be considered for data analysis."},{"metadata":{},"cell_type":"markdown","source":"events.csv contains data about events in our system, and has 110 columns.  The first nine columns are event_id, user_id, start_time, city, state, zip, country, lat, and lng.  event_id is the id of the event, and user_id is the id of the user who created the event.  city, state, zip, and country represent more details about the location of the venue (if known).  lat and lng are floats representing the latitude and longitude coordinates of the venue, rounded to three decimal places.  start_time is the ISO-8601 UTC time string representing when the event is scheduled to begin.  The last 101 columns require a bit more explanation; first, we determined the 100 most common word stems (obtained via Porter Stemming) occuring in the name or description of a large random subset of our events.  The last 101 columns are count_1, count_2, ..., count_100, count_other, where count_N is an integer representing the number of times the Nth most common word stem appears in the name or description of this event.  count_other is a count of the rest of the words whose stem wasn't one of the 100 most common stems."},{"metadata":{"trusted":true},"cell_type":"code","source":"events = pd.read_csv('/kaggle/input/event-recommendation-engine-challenge/events.csv.gz', compression = 'gzip')\nevents.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"events.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"events.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"events.event_id.value_counts().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"events.isnull().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(events.city.value_counts())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"event_attendees.csv contains information about which users attended various events, and has the following columns: event_id, yes, maybe, invited, and no. event_id identifies the event. yes, maybe, invited, and no are space-delimited lists of user id's representing users who indicated that they were going, maybe going, invited to, or not going to the event."},{"metadata":{"trusted":true},"cell_type":"code","source":"event_attendees = pd.read_csv('/kaggle/input/event-recommendation-engine-challenge/event_attendees.csv.gz', compression= 'gzip')\nevent_attendees.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"event_attendees.yes[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Change string of attendees into list (yes attribute)\nfor i in range(event_attendees.shape[0]):\n    attendees = list()\n    attendees = str(event_attendees.yes[i]).split()\n    event_attendees.yes[i]=attendees\n    print(event_attendees.event[i], attendees)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"event_attendees.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Change string of attendees into list (maybe attribute)\nfor i in range(event_attendees.shape[0]):\n    attendees = list()\n    attendees = str(event_attendees.maybe[i]).split()\n    event_attendees.maybe[i]=attendees\n#     print(event_attendees.event[i], attendees)\n\n# Change string of attendees into list (no attribute)\nfor i in range(event_attendees.shape[0]):\n    attendees = list()\n    attendees = str(event_attendees.no[i]).split()\n    event_attendees.no[i]=attendees\n#     print(event_attendees.event[i], attendees)    \n\n# Change string of attendees into list (invited attribute)\nfor i in range(event_attendees.shape[0]):\n    attendees = list()\n    attendees = str(event_attendees.invited[i]).split()\n    event_attendees.invited[i]=attendees\n#     print(event_attendees.event[i], attendees)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"users.csv contains demographic data about our some of our users (including all of the users appearing in the train and test files), and it has the following columns: user_id, locale, birthyear, gender, joinedAt, location, and timezone. user_id is the id of the user in our system.  locale is a string representing the user's locale, which should be of the form language_territory. birthyear is a 4-digit integer representing the year when the user was born. gender is either male or female, depending on the user's gender.  joinedAt is an ISO-8601 UTC time string representing when the user first used our application.  location is a string representing the user's location (if known).  timezone is a signed integer representing the user's UTC offset (in minutes)."},{"metadata":{"trusted":true},"cell_type":"code","source":"users = pd.read_csv('/kaggle/input/event-recommendation-engine-challenge/users.csv')\nusers.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"users.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"users.isnull().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"users.location.value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import seaborn as sns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# plt.figure(figsize=(10,5))\n\nchart = sns.countplot(users.location,\n              order=users.location.value_counts().iloc[:10].index)\nchart.set_xticklabels(chart.get_xticklabels(), rotation=90, horizontalalignment='right')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"users.locale.value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"chart = sns.countplot(users.locale,\n              order=users.locale.value_counts().iloc[:10].index)\nchart.set_xticklabels(chart.get_xticklabels(), rotation=90, horizontalalignment='right')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"user_friends.csv contains social data about this user, and contains two columns:  user and friends.  user is the user's id in our system, and friends is a space-delimited list of the user's friends' ids."},{"metadata":{"trusted":true},"cell_type":"code","source":"user_friends = pd.read_csv('../input/event-recommendation-engine-challenge/user_friends.csv.gz', compression = 'gzip')\nuser_friends.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Change string of friends into list\nfor i in range(user_friends.shape[0]):\n    friends = list()\n    friends = str(user_friends.friends[i]).split()\n    user_friends.friends[i]=friends","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"user_friends.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"user_friends.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":""}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}