Upload 8 files
Browse files- .gitattributes +3 -0
- Dataset____Multi_Destination_Trips.pdf +3 -0
- Readme.md +60 -0
- evaluation_demo.ipynb +621 -0
- ground_truth.csv +0 -0
- mlt_example.jpg +3 -0
- submission.csv +0 -0
- test_set.csv +3 -0
- train_set.csv +3 -0
.gitattributes
CHANGED
@@ -57,3 +57,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
57 |
# Video files - compressed
|
58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
57 |
# Video files - compressed
|
58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
60 |
+
Dataset____Multi_Destination_Trips.pdf filter=lfs diff=lfs merge=lfs -text
|
61 |
+
test_set.csv filter=lfs diff=lfs merge=lfs -text
|
62 |
+
train_set.csv filter=lfs diff=lfs merge=lfs -text
|
Dataset____Multi_Destination_Trips.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f8de70b26f0b8536e269d224331191658d96a38448f036dc4e1d58dcd28b59d7
|
3 |
+
size 1622609
|
Readme.md
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Intro
|
2 |
+
----------------------
|
3 |
+
Booking.com provides a unique dataset based on millions of real anonymized bookings to encourage the research on sequential recommendation problems.
|
4 |
+
Many travelers go on trips which include more than one destination. Our mission at Booking.com is to make it easier for everyone to experience the world, and we can help to do that by providing real-time recommendations for what their next in-trip destination will be. By making accurate predictions, we help deliver a frictionless trip planning experience.
|
5 |
+
The main challenge is to use a dataset based on millions of real anonymized accommodation reservations to come up with a strategy for making the best recommendation for their next destination in real-time.
|
6 |
+
|
7 |
+
![Multi-Destination Trip recommendation bar at booking.com](https://github.com/bookingcom/ml-dataset-mdt/blob/main/mlt_example.jpg)
|
8 |
+
|
9 |
+
## Dataset
|
10 |
+
-------------------
|
11 |
+
The training dataset consists of over a million (1,166,835) of anonymized hotel reservations, based on real data, with the following features:
|
12 |
+
- user_id - User ID
|
13 |
+
- checkin - Reservation check-in date
|
14 |
+
- checkout - Reservation check-out date- created_date - Date when the reservation was made
|
15 |
+
- affiliate_id - An anonymized ID of affiliate channels where the booker came from (e.g. direct, some third party referrals, paid search engine, etc.)
|
16 |
+
- device_class - desktop/mobile
|
17 |
+
- booker_country - Country from which the reservation was made (anonymized)
|
18 |
+
- hotel_country - Country of the hotel (anonymized)
|
19 |
+
- city_id - city_id of the hotel's city (anonymized)
|
20 |
+
- utrip_id - Unique identification of user's trip (a group of multi-destinations bookings within the same trip).
|
21 |
+
|
22 |
+
Each reservation is a part of a customer's trip (identified by utrip_id) which includes consecutive reservations.
|
23 |
+
The evaluation dataset is constructed similarly (378,667 reservations), however the city_id (and the country) of the final reservation of each trip is concealed and requires a prediction.
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
## Citing
|
28 |
+
----------------------
|
29 |
+
Booking.com Multi-Destination Trips Dataset is published as a [resource paper at SIGIR '21](https://doi.org/10.1145/3404835.3463240). Please refer to dataset in research publications in the following format:
|
30 |
+
|
31 |
+
*Dmitri Goldenberg and Pavel Levin. 2021. Booking.com Multi-Destination Trips Dataset. In Proceedings of the 44th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR ’21), July 11–15, 2021, Virtual Event, Canada.*
|
32 |
+
|
33 |
+
#### BibTex:
|
34 |
+
```
|
35 |
+
@inproceedings{goldenberg2021dataset,
|
36 |
+
author = {Goldenberg, Dmitri and Levin, Pavel},
|
37 |
+
title = {Booking.com Multi-Destination Trips Dataset},
|
38 |
+
booktitle = {Proceedings of the 44th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR ’21)},
|
39 |
+
year = {2021},
|
40 |
+
doi = {10.1145/3404835.3463240}}
|
41 |
+
```
|
42 |
+
|
43 |
+
For more details, please refer to [Booking.com challenge website](https://www.bookingchallenge.com/) and the [Booking.ai blog](https://booking.ai/).
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
## Attachments
|
48 |
+
----------------------
|
49 |
+
- train_set.csv - Training dataset
|
50 |
+
- test_set.csv - Validation test set data (with a concealed last destination) as used in Booking.com WSDM WebTour challenge
|
51 |
+
- ground_truth.csv - The true values of the test set
|
52 |
+
- submission.csv - an example submission for the test data
|
53 |
+
- evaluation_demo.ipynb - a Jupyter notebook exampling train set loading, submission generation for test set and evaluation function
|
54 |
+
|
55 |
+
|
56 |
+
## Terms and Conditions
|
57 |
+
----------------------
|
58 |
+
- The dataset is a property of Booking.com and may not be reused for commercial purposes.
|
59 |
+
- The dataset may not be used in a manner that is harmful or competitive in nature with Booking.com or Booking Holdings.
|
60 |
+
- The dataset may not be used in any manner or for any purpose that may violate any law or regulation.
|
evaluation_demo.ipynb
ADDED
@@ -0,0 +1,621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Booking.com Multi-Destinations Trips Dataset demo"
|
8 |
+
]
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"cell_type": "code",
|
12 |
+
"execution_count": 1,
|
13 |
+
"metadata": {},
|
14 |
+
"outputs": [],
|
15 |
+
"source": [
|
16 |
+
"import pandas as pd"
|
17 |
+
]
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"cell_type": "markdown",
|
21 |
+
"metadata": {},
|
22 |
+
"source": [
|
23 |
+
"## Load train set"
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"cell_type": "code",
|
28 |
+
"execution_count": 2,
|
29 |
+
"metadata": {},
|
30 |
+
"outputs": [
|
31 |
+
{
|
32 |
+
"name": "stdout",
|
33 |
+
"output_type": "stream",
|
34 |
+
"text": [
|
35 |
+
"(1166835, 9)\n"
|
36 |
+
]
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"data": {
|
40 |
+
"text/html": [
|
41 |
+
"<div>\n",
|
42 |
+
"<style scoped>\n",
|
43 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
44 |
+
" vertical-align: middle;\n",
|
45 |
+
" }\n",
|
46 |
+
"\n",
|
47 |
+
" .dataframe tbody tr th {\n",
|
48 |
+
" vertical-align: top;\n",
|
49 |
+
" }\n",
|
50 |
+
"\n",
|
51 |
+
" .dataframe thead th {\n",
|
52 |
+
" text-align: right;\n",
|
53 |
+
" }\n",
|
54 |
+
"</style>\n",
|
55 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
56 |
+
" <thead>\n",
|
57 |
+
" <tr style=\"text-align: right;\">\n",
|
58 |
+
" <th></th>\n",
|
59 |
+
" <th>user_id</th>\n",
|
60 |
+
" <th>checkin</th>\n",
|
61 |
+
" <th>checkout</th>\n",
|
62 |
+
" <th>city_id</th>\n",
|
63 |
+
" <th>device_class</th>\n",
|
64 |
+
" <th>affiliate_id</th>\n",
|
65 |
+
" <th>booker_country</th>\n",
|
66 |
+
" <th>hotel_country</th>\n",
|
67 |
+
" <th>utrip_id</th>\n",
|
68 |
+
" </tr>\n",
|
69 |
+
" </thead>\n",
|
70 |
+
" <tbody>\n",
|
71 |
+
" <tr>\n",
|
72 |
+
" <th>0</th>\n",
|
73 |
+
" <td>1000027</td>\n",
|
74 |
+
" <td>2016-08-13</td>\n",
|
75 |
+
" <td>2016-08-14</td>\n",
|
76 |
+
" <td>8183</td>\n",
|
77 |
+
" <td>desktop</td>\n",
|
78 |
+
" <td>7168</td>\n",
|
79 |
+
" <td>Elbonia</td>\n",
|
80 |
+
" <td>Gondal</td>\n",
|
81 |
+
" <td>1000027_1</td>\n",
|
82 |
+
" </tr>\n",
|
83 |
+
" <tr>\n",
|
84 |
+
" <th>1</th>\n",
|
85 |
+
" <td>1000027</td>\n",
|
86 |
+
" <td>2016-08-14</td>\n",
|
87 |
+
" <td>2016-08-16</td>\n",
|
88 |
+
" <td>15626</td>\n",
|
89 |
+
" <td>desktop</td>\n",
|
90 |
+
" <td>7168</td>\n",
|
91 |
+
" <td>Elbonia</td>\n",
|
92 |
+
" <td>Gondal</td>\n",
|
93 |
+
" <td>1000027_1</td>\n",
|
94 |
+
" </tr>\n",
|
95 |
+
" <tr>\n",
|
96 |
+
" <th>2</th>\n",
|
97 |
+
" <td>1000027</td>\n",
|
98 |
+
" <td>2016-08-16</td>\n",
|
99 |
+
" <td>2016-08-18</td>\n",
|
100 |
+
" <td>60902</td>\n",
|
101 |
+
" <td>desktop</td>\n",
|
102 |
+
" <td>7168</td>\n",
|
103 |
+
" <td>Elbonia</td>\n",
|
104 |
+
" <td>Gondal</td>\n",
|
105 |
+
" <td>1000027_1</td>\n",
|
106 |
+
" </tr>\n",
|
107 |
+
" <tr>\n",
|
108 |
+
" <th>3</th>\n",
|
109 |
+
" <td>1000027</td>\n",
|
110 |
+
" <td>2016-08-18</td>\n",
|
111 |
+
" <td>2016-08-21</td>\n",
|
112 |
+
" <td>30628</td>\n",
|
113 |
+
" <td>desktop</td>\n",
|
114 |
+
" <td>253</td>\n",
|
115 |
+
" <td>Elbonia</td>\n",
|
116 |
+
" <td>Gondal</td>\n",
|
117 |
+
" <td>1000027_1</td>\n",
|
118 |
+
" </tr>\n",
|
119 |
+
" <tr>\n",
|
120 |
+
" <th>4</th>\n",
|
121 |
+
" <td>1000033</td>\n",
|
122 |
+
" <td>2016-04-09</td>\n",
|
123 |
+
" <td>2016-04-11</td>\n",
|
124 |
+
" <td>38677</td>\n",
|
125 |
+
" <td>mobile</td>\n",
|
126 |
+
" <td>359</td>\n",
|
127 |
+
" <td>Gondal</td>\n",
|
128 |
+
" <td>Cobra Island</td>\n",
|
129 |
+
" <td>1000033_1</td>\n",
|
130 |
+
" </tr>\n",
|
131 |
+
" </tbody>\n",
|
132 |
+
"</table>\n",
|
133 |
+
"</div>"
|
134 |
+
],
|
135 |
+
"text/plain": [
|
136 |
+
" user_id checkin checkout city_id device_class affiliate_id \\\n",
|
137 |
+
"0 1000027 2016-08-13 2016-08-14 8183 desktop 7168 \n",
|
138 |
+
"1 1000027 2016-08-14 2016-08-16 15626 desktop 7168 \n",
|
139 |
+
"2 1000027 2016-08-16 2016-08-18 60902 desktop 7168 \n",
|
140 |
+
"3 1000027 2016-08-18 2016-08-21 30628 desktop 253 \n",
|
141 |
+
"4 1000033 2016-04-09 2016-04-11 38677 mobile 359 \n",
|
142 |
+
"\n",
|
143 |
+
" booker_country hotel_country utrip_id \n",
|
144 |
+
"0 Elbonia Gondal 1000027_1 \n",
|
145 |
+
"1 Elbonia Gondal 1000027_1 \n",
|
146 |
+
"2 Elbonia Gondal 1000027_1 \n",
|
147 |
+
"3 Elbonia Gondal 1000027_1 \n",
|
148 |
+
"4 Gondal Cobra Island 1000033_1 "
|
149 |
+
]
|
150 |
+
},
|
151 |
+
"execution_count": 2,
|
152 |
+
"metadata": {},
|
153 |
+
"output_type": "execute_result"
|
154 |
+
}
|
155 |
+
],
|
156 |
+
"source": [
|
157 |
+
"train_set = pd.read_csv('train_set.csv').sort_values(by=['utrip_id','checkin'])\n",
|
158 |
+
"\n",
|
159 |
+
"print(train_set.shape)\n",
|
160 |
+
"train_set.head()"
|
161 |
+
]
|
162 |
+
},
|
163 |
+
{
|
164 |
+
"cell_type": "markdown",
|
165 |
+
"metadata": {},
|
166 |
+
"source": [
|
167 |
+
"### Load testset"
|
168 |
+
]
|
169 |
+
},
|
170 |
+
{
|
171 |
+
"cell_type": "code",
|
172 |
+
"execution_count": 3,
|
173 |
+
"metadata": {},
|
174 |
+
"outputs": [
|
175 |
+
{
|
176 |
+
"name": "stdout",
|
177 |
+
"output_type": "stream",
|
178 |
+
"text": [
|
179 |
+
"(378667, 9)\n"
|
180 |
+
]
|
181 |
+
},
|
182 |
+
{
|
183 |
+
"data": {
|
184 |
+
"text/html": [
|
185 |
+
"<div>\n",
|
186 |
+
"<style scoped>\n",
|
187 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
188 |
+
" vertical-align: middle;\n",
|
189 |
+
" }\n",
|
190 |
+
"\n",
|
191 |
+
" .dataframe tbody tr th {\n",
|
192 |
+
" vertical-align: top;\n",
|
193 |
+
" }\n",
|
194 |
+
"\n",
|
195 |
+
" .dataframe thead th {\n",
|
196 |
+
" text-align: right;\n",
|
197 |
+
" }\n",
|
198 |
+
"</style>\n",
|
199 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
200 |
+
" <thead>\n",
|
201 |
+
" <tr style=\"text-align: right;\">\n",
|
202 |
+
" <th></th>\n",
|
203 |
+
" <th>user_id</th>\n",
|
204 |
+
" <th>checkin</th>\n",
|
205 |
+
" <th>checkout</th>\n",
|
206 |
+
" <th>device_class</th>\n",
|
207 |
+
" <th>affiliate_id</th>\n",
|
208 |
+
" <th>booker_country</th>\n",
|
209 |
+
" <th>utrip_id</th>\n",
|
210 |
+
" <th>city_id</th>\n",
|
211 |
+
" <th>hotel_country</th>\n",
|
212 |
+
" </tr>\n",
|
213 |
+
" </thead>\n",
|
214 |
+
" <tbody>\n",
|
215 |
+
" <tr>\n",
|
216 |
+
" <th>0</th>\n",
|
217 |
+
" <td>1000066</td>\n",
|
218 |
+
" <td>2016-07-21</td>\n",
|
219 |
+
" <td>2016-07-23</td>\n",
|
220 |
+
" <td>desktop</td>\n",
|
221 |
+
" <td>9924</td>\n",
|
222 |
+
" <td>Gondal</td>\n",
|
223 |
+
" <td>1000066_2</td>\n",
|
224 |
+
" <td>56430</td>\n",
|
225 |
+
" <td>Urkesh</td>\n",
|
226 |
+
" </tr>\n",
|
227 |
+
" <tr>\n",
|
228 |
+
" <th>1</th>\n",
|
229 |
+
" <td>1000066</td>\n",
|
230 |
+
" <td>2016-07-23</td>\n",
|
231 |
+
" <td>2016-07-25</td>\n",
|
232 |
+
" <td>desktop</td>\n",
|
233 |
+
" <td>9924</td>\n",
|
234 |
+
" <td>Gondal</td>\n",
|
235 |
+
" <td>1000066_2</td>\n",
|
236 |
+
" <td>41971</td>\n",
|
237 |
+
" <td>Urkesh</td>\n",
|
238 |
+
" </tr>\n",
|
239 |
+
" <tr>\n",
|
240 |
+
" <th>2</th>\n",
|
241 |
+
" <td>1000066</td>\n",
|
242 |
+
" <td>2016-07-25</td>\n",
|
243 |
+
" <td>2016-07-28</td>\n",
|
244 |
+
" <td>desktop</td>\n",
|
245 |
+
" <td>9924</td>\n",
|
246 |
+
" <td>Gondal</td>\n",
|
247 |
+
" <td>1000066_2</td>\n",
|
248 |
+
" <td>5797</td>\n",
|
249 |
+
" <td>Urkesh</td>\n",
|
250 |
+
" </tr>\n",
|
251 |
+
" <tr>\n",
|
252 |
+
" <th>3</th>\n",
|
253 |
+
" <td>1000066</td>\n",
|
254 |
+
" <td>2016-07-28</td>\n",
|
255 |
+
" <td>2016-07-31</td>\n",
|
256 |
+
" <td>mobile</td>\n",
|
257 |
+
" <td>2436</td>\n",
|
258 |
+
" <td>Gondal</td>\n",
|
259 |
+
" <td>1000066_2</td>\n",
|
260 |
+
" <td>0</td>\n",
|
261 |
+
" <td>NaN</td>\n",
|
262 |
+
" </tr>\n",
|
263 |
+
" <tr>\n",
|
264 |
+
" <th>4</th>\n",
|
265 |
+
" <td>1000270</td>\n",
|
266 |
+
" <td>2016-02-08</td>\n",
|
267 |
+
" <td>2016-02-09</td>\n",
|
268 |
+
" <td>mobile</td>\n",
|
269 |
+
" <td>9452</td>\n",
|
270 |
+
" <td>The Devilfire Empire</td>\n",
|
271 |
+
" <td>1000270_1</td>\n",
|
272 |
+
" <td>50075</td>\n",
|
273 |
+
" <td>The Devilfire Empire</td>\n",
|
274 |
+
" </tr>\n",
|
275 |
+
" </tbody>\n",
|
276 |
+
"</table>\n",
|
277 |
+
"</div>"
|
278 |
+
],
|
279 |
+
"text/plain": [
|
280 |
+
" user_id checkin checkout device_class affiliate_id \\\n",
|
281 |
+
"0 1000066 2016-07-21 2016-07-23 desktop 9924 \n",
|
282 |
+
"1 1000066 2016-07-23 2016-07-25 desktop 9924 \n",
|
283 |
+
"2 1000066 2016-07-25 2016-07-28 desktop 9924 \n",
|
284 |
+
"3 1000066 2016-07-28 2016-07-31 mobile 2436 \n",
|
285 |
+
"4 1000270 2016-02-08 2016-02-09 mobile 9452 \n",
|
286 |
+
"\n",
|
287 |
+
" booker_country utrip_id city_id hotel_country \n",
|
288 |
+
"0 Gondal 1000066_2 56430 Urkesh \n",
|
289 |
+
"1 Gondal 1000066_2 41971 Urkesh \n",
|
290 |
+
"2 Gondal 1000066_2 5797 Urkesh \n",
|
291 |
+
"3 Gondal 1000066_2 0 NaN \n",
|
292 |
+
"4 The Devilfire Empire 1000270_1 50075 The Devilfire Empire "
|
293 |
+
]
|
294 |
+
},
|
295 |
+
"execution_count": 3,
|
296 |
+
"metadata": {},
|
297 |
+
"output_type": "execute_result"
|
298 |
+
}
|
299 |
+
],
|
300 |
+
"source": [
|
301 |
+
"test_set = pd.read_csv('test_set.csv').sort_values(by=['utrip_id','checkin'])\n",
|
302 |
+
"print(test_set.shape)\n",
|
303 |
+
"\n",
|
304 |
+
"test_set.head()"
|
305 |
+
]
|
306 |
+
},
|
307 |
+
{
|
308 |
+
"cell_type": "markdown",
|
309 |
+
"metadata": {},
|
310 |
+
"source": [
|
311 |
+
"### Generate Dummy Predictions - use top 4 cities in the trainset as benchmark recommendation"
|
312 |
+
]
|
313 |
+
},
|
314 |
+
{
|
315 |
+
"cell_type": "code",
|
316 |
+
"execution_count": 4,
|
317 |
+
"metadata": {},
|
318 |
+
"outputs": [],
|
319 |
+
"source": [
|
320 |
+
"topcities = train_set.city_id.value_counts().index[:4]\n",
|
321 |
+
"\n",
|
322 |
+
"test_trips = (test_set[['utrip_id']].drop_duplicates()).reset_index().drop('index', axis=1)\n",
|
323 |
+
"cities_prediction = pd.DataFrame([topcities]*test_trips.shape[0]\n",
|
324 |
+
" , columns= ['city_id_1','city_id_2','city_id_3','city_id_4'])"
|
325 |
+
]
|
326 |
+
},
|
327 |
+
{
|
328 |
+
"cell_type": "markdown",
|
329 |
+
"metadata": {},
|
330 |
+
"source": [
|
331 |
+
"### Create Submission file according to the format"
|
332 |
+
]
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"cell_type": "code",
|
336 |
+
"execution_count": 5,
|
337 |
+
"metadata": {},
|
338 |
+
"outputs": [
|
339 |
+
{
|
340 |
+
"name": "stdout",
|
341 |
+
"output_type": "stream",
|
342 |
+
"text": [
|
343 |
+
"(70662, 5)\n"
|
344 |
+
]
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"data": {
|
348 |
+
"text/html": [
|
349 |
+
"<div>\n",
|
350 |
+
"<style scoped>\n",
|
351 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
352 |
+
" vertical-align: middle;\n",
|
353 |
+
" }\n",
|
354 |
+
"\n",
|
355 |
+
" .dataframe tbody tr th {\n",
|
356 |
+
" vertical-align: top;\n",
|
357 |
+
" }\n",
|
358 |
+
"\n",
|
359 |
+
" .dataframe thead th {\n",
|
360 |
+
" text-align: right;\n",
|
361 |
+
" }\n",
|
362 |
+
"</style>\n",
|
363 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
364 |
+
" <thead>\n",
|
365 |
+
" <tr style=\"text-align: right;\">\n",
|
366 |
+
" <th></th>\n",
|
367 |
+
" <th>utrip_id</th>\n",
|
368 |
+
" <th>city_id_1</th>\n",
|
369 |
+
" <th>city_id_2</th>\n",
|
370 |
+
" <th>city_id_3</th>\n",
|
371 |
+
" <th>city_id_4</th>\n",
|
372 |
+
" </tr>\n",
|
373 |
+
" </thead>\n",
|
374 |
+
" <tbody>\n",
|
375 |
+
" <tr>\n",
|
376 |
+
" <th>0</th>\n",
|
377 |
+
" <td>1000066_2</td>\n",
|
378 |
+
" <td>47499</td>\n",
|
379 |
+
" <td>23921</td>\n",
|
380 |
+
" <td>36063</td>\n",
|
381 |
+
" <td>17013</td>\n",
|
382 |
+
" </tr>\n",
|
383 |
+
" <tr>\n",
|
384 |
+
" <th>1</th>\n",
|
385 |
+
" <td>1000270_1</td>\n",
|
386 |
+
" <td>47499</td>\n",
|
387 |
+
" <td>23921</td>\n",
|
388 |
+
" <td>36063</td>\n",
|
389 |
+
" <td>17013</td>\n",
|
390 |
+
" </tr>\n",
|
391 |
+
" <tr>\n",
|
392 |
+
" <th>2</th>\n",
|
393 |
+
" <td>1000441_1</td>\n",
|
394 |
+
" <td>47499</td>\n",
|
395 |
+
" <td>23921</td>\n",
|
396 |
+
" <td>36063</td>\n",
|
397 |
+
" <td>17013</td>\n",
|
398 |
+
" </tr>\n",
|
399 |
+
" <tr>\n",
|
400 |
+
" <th>3</th>\n",
|
401 |
+
" <td>100048_1</td>\n",
|
402 |
+
" <td>47499</td>\n",
|
403 |
+
" <td>23921</td>\n",
|
404 |
+
" <td>36063</td>\n",
|
405 |
+
" <td>17013</td>\n",
|
406 |
+
" </tr>\n",
|
407 |
+
" <tr>\n",
|
408 |
+
" <th>4</th>\n",
|
409 |
+
" <td>1000543_1</td>\n",
|
410 |
+
" <td>47499</td>\n",
|
411 |
+
" <td>23921</td>\n",
|
412 |
+
" <td>36063</td>\n",
|
413 |
+
" <td>17013</td>\n",
|
414 |
+
" </tr>\n",
|
415 |
+
" </tbody>\n",
|
416 |
+
"</table>\n",
|
417 |
+
"</div>"
|
418 |
+
],
|
419 |
+
"text/plain": [
|
420 |
+
" utrip_id city_id_1 city_id_2 city_id_3 city_id_4\n",
|
421 |
+
"0 1000066_2 47499 23921 36063 17013\n",
|
422 |
+
"1 1000270_1 47499 23921 36063 17013\n",
|
423 |
+
"2 1000441_1 47499 23921 36063 17013\n",
|
424 |
+
"3 100048_1 47499 23921 36063 17013\n",
|
425 |
+
"4 1000543_1 47499 23921 36063 17013"
|
426 |
+
]
|
427 |
+
},
|
428 |
+
"execution_count": 5,
|
429 |
+
"metadata": {},
|
430 |
+
"output_type": "execute_result"
|
431 |
+
}
|
432 |
+
],
|
433 |
+
"source": [
|
434 |
+
"submission = pd.concat([test_trips,cities_prediction], axis =1)\n",
|
435 |
+
"print(submission.shape)\n",
|
436 |
+
"submission.head()"
|
437 |
+
]
|
438 |
+
},
|
439 |
+
{
|
440 |
+
"cell_type": "code",
|
441 |
+
"execution_count": 6,
|
442 |
+
"metadata": {},
|
443 |
+
"outputs": [],
|
444 |
+
"source": [
|
445 |
+
"submission.to_csv('submission.csv',index=False)"
|
446 |
+
]
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"cell_type": "markdown",
|
450 |
+
"metadata": {},
|
451 |
+
"source": [
|
452 |
+
"## Read submission file and ground truth"
|
453 |
+
]
|
454 |
+
},
|
455 |
+
{
|
456 |
+
"cell_type": "code",
|
457 |
+
"execution_count": 7,
|
458 |
+
"metadata": {},
|
459 |
+
"outputs": [],
|
460 |
+
"source": [
|
461 |
+
"ground_truth = pd.read_csv('ground_truth.csv',index_col=[0])\n",
|
462 |
+
"submission = pd.read_csv('submission.csv',index_col=[0])"
|
463 |
+
]
|
464 |
+
},
|
465 |
+
{
|
466 |
+
"cell_type": "code",
|
467 |
+
"execution_count": 8,
|
468 |
+
"metadata": {},
|
469 |
+
"outputs": [
|
470 |
+
{
|
471 |
+
"name": "stdout",
|
472 |
+
"output_type": "stream",
|
473 |
+
"text": [
|
474 |
+
"(70662, 2)\n"
|
475 |
+
]
|
476 |
+
},
|
477 |
+
{
|
478 |
+
"data": {
|
479 |
+
"text/html": [
|
480 |
+
"<div>\n",
|
481 |
+
"<style scoped>\n",
|
482 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
483 |
+
" vertical-align: middle;\n",
|
484 |
+
" }\n",
|
485 |
+
"\n",
|
486 |
+
" .dataframe tbody tr th {\n",
|
487 |
+
" vertical-align: top;\n",
|
488 |
+
" }\n",
|
489 |
+
"\n",
|
490 |
+
" .dataframe thead th {\n",
|
491 |
+
" text-align: right;\n",
|
492 |
+
" }\n",
|
493 |
+
"</style>\n",
|
494 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
495 |
+
" <thead>\n",
|
496 |
+
" <tr style=\"text-align: right;\">\n",
|
497 |
+
" <th></th>\n",
|
498 |
+
" <th>city_id</th>\n",
|
499 |
+
" <th>hotel_country</th>\n",
|
500 |
+
" </tr>\n",
|
501 |
+
" <tr>\n",
|
502 |
+
" <th>utrip_id</th>\n",
|
503 |
+
" <th></th>\n",
|
504 |
+
" <th></th>\n",
|
505 |
+
" </tr>\n",
|
506 |
+
" </thead>\n",
|
507 |
+
" <tbody>\n",
|
508 |
+
" <tr>\n",
|
509 |
+
" <th>1038944_1</th>\n",
|
510 |
+
" <td>54085</td>\n",
|
511 |
+
" <td>Sokovia</td>\n",
|
512 |
+
" </tr>\n",
|
513 |
+
" <tr>\n",
|
514 |
+
" <th>1068715_1</th>\n",
|
515 |
+
" <td>29319</td>\n",
|
516 |
+
" <td>Cobra Island</td>\n",
|
517 |
+
" </tr>\n",
|
518 |
+
" <tr>\n",
|
519 |
+
" <th>1075528_1</th>\n",
|
520 |
+
" <td>55763</td>\n",
|
521 |
+
" <td>Bozatta</td>\n",
|
522 |
+
" </tr>\n",
|
523 |
+
" <tr>\n",
|
524 |
+
" <th>1110462_4</th>\n",
|
525 |
+
" <td>11930</td>\n",
|
526 |
+
" <td>Alvonia</td>\n",
|
527 |
+
" </tr>\n",
|
528 |
+
" <tr>\n",
|
529 |
+
" <th>1132565_1</th>\n",
|
530 |
+
" <td>58659</td>\n",
|
531 |
+
" <td>Axphain</td>\n",
|
532 |
+
" </tr>\n",
|
533 |
+
" </tbody>\n",
|
534 |
+
"</table>\n",
|
535 |
+
"</div>"
|
536 |
+
],
|
537 |
+
"text/plain": [
|
538 |
+
" city_id hotel_country\n",
|
539 |
+
"utrip_id \n",
|
540 |
+
"1038944_1 54085 Sokovia\n",
|
541 |
+
"1068715_1 29319 Cobra Island\n",
|
542 |
+
"1075528_1 55763 Bozatta\n",
|
543 |
+
"1110462_4 11930 Alvonia\n",
|
544 |
+
"1132565_1 58659 Axphain"
|
545 |
+
]
|
546 |
+
},
|
547 |
+
"execution_count": 8,
|
548 |
+
"metadata": {},
|
549 |
+
"output_type": "execute_result"
|
550 |
+
}
|
551 |
+
],
|
552 |
+
"source": [
|
553 |
+
"print(ground_truth.shape)\n",
|
554 |
+
"ground_truth.head()"
|
555 |
+
]
|
556 |
+
},
|
557 |
+
{
|
558 |
+
"cell_type": "markdown",
|
559 |
+
"metadata": {},
|
560 |
+
"source": [
|
561 |
+
"## Evaluate - use accuracy at 4 to evaluate the prediction"
|
562 |
+
]
|
563 |
+
},
|
564 |
+
{
|
565 |
+
"cell_type": "code",
|
566 |
+
"execution_count": 9,
|
567 |
+
"metadata": {},
|
568 |
+
"outputs": [],
|
569 |
+
"source": [
|
570 |
+
"def evaluate_accuracy_at_4(submission,ground_truth):\n",
|
571 |
+
" '''checks if the true city is within the four recommended cities'''\n",
|
572 |
+
" data = submission.join(ground_truth,on='utrip_id')\n",
|
573 |
+
"\n",
|
574 |
+
" hits = ((data['city_id']==data['city_id_1'])|(data['city_id']==data['city_id_2'])|\n",
|
575 |
+
" (data['city_id']==data['city_id_3'])|(data['city_id']==data['city_id_4']))*1\n",
|
576 |
+
" return hits.mean()"
|
577 |
+
]
|
578 |
+
},
|
579 |
+
{
|
580 |
+
"cell_type": "code",
|
581 |
+
"execution_count": 10,
|
582 |
+
"metadata": {},
|
583 |
+
"outputs": [
|
584 |
+
{
|
585 |
+
"data": {
|
586 |
+
"text/plain": [
|
587 |
+
"0.05271574537941185"
|
588 |
+
]
|
589 |
+
},
|
590 |
+
"execution_count": 10,
|
591 |
+
"metadata": {},
|
592 |
+
"output_type": "execute_result"
|
593 |
+
}
|
594 |
+
],
|
595 |
+
"source": [
|
596 |
+
"evaluate_accuracy_at_4(submission,ground_truth)"
|
597 |
+
]
|
598 |
+
}
|
599 |
+
],
|
600 |
+
"metadata": {
|
601 |
+
"kernelspec": {
|
602 |
+
"display_name": "Python 3",
|
603 |
+
"language": "python",
|
604 |
+
"name": "python3"
|
605 |
+
},
|
606 |
+
"language_info": {
|
607 |
+
"codemirror_mode": {
|
608 |
+
"name": "ipython",
|
609 |
+
"version": 3
|
610 |
+
},
|
611 |
+
"file_extension": ".py",
|
612 |
+
"mimetype": "text/x-python",
|
613 |
+
"name": "python",
|
614 |
+
"nbconvert_exporter": "python",
|
615 |
+
"pygments_lexer": "ipython3",
|
616 |
+
"version": "3.8.3"
|
617 |
+
}
|
618 |
+
},
|
619 |
+
"nbformat": 4,
|
620 |
+
"nbformat_minor": 4
|
621 |
+
}
|
ground_truth.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
mlt_example.jpg
ADDED
Git LFS Details
|
submission.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
test_set.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9686f23d9604a4e2cb6f287d0a5282d922732a0a5120746c2a68f934e2530dca
|
3 |
+
size 29150292
|
train_set.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ad7bfeb3d6e8621862a03e8491545d3b9134ba87c0fb8fce12864580f95662e7
|
3 |
+
size 92651064
|