Gansol commited on
Commit
76e9403
1 Parent(s): 66f51cf

Upload PIM2_inf_Allen.ipynb

Browse files
Files changed (1) hide show
  1. PIM2_inf_Allen.ipynb +202 -0
PIM2_inf_Allen.ipynb ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "#Import Library\n",
10
+ "import pandas as pd \n",
11
+ "import numpy as np \n",
12
+ "import pickle "
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 3,
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "# Open Best Params\n",
22
+ "with open('best_param.pkl', 'rb') as file_1:\n",
23
+ " best_params = pickle.load(file_1)"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 4,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "# Open Preprocessing\n",
33
+ "with open('preprocessing_pipeline.pkl', 'rb') as file_2:\n",
34
+ " preprocessing_pipeline= pickle.load(file_2)"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 6,
40
+ "metadata": {},
41
+ "outputs": [
42
+ {
43
+ "data": {
44
+ "text/html": [
45
+ "<div>\n",
46
+ "<style scoped>\n",
47
+ " .dataframe tbody tr th:only-of-type {\n",
48
+ " vertical-align: middle;\n",
49
+ " }\n",
50
+ "\n",
51
+ " .dataframe tbody tr th {\n",
52
+ " vertical-align: top;\n",
53
+ " }\n",
54
+ "\n",
55
+ " .dataframe thead th {\n",
56
+ " text-align: right;\n",
57
+ " }\n",
58
+ "</style>\n",
59
+ "<table border=\"1\" class=\"dataframe\">\n",
60
+ " <thead>\n",
61
+ " <tr style=\"text-align: right;\">\n",
62
+ " <th></th>\n",
63
+ " <th>Booking_ID</th>\n",
64
+ " <th>no_of_adults</th>\n",
65
+ " <th>no_of_children</th>\n",
66
+ " <th>no_of_weekend_nights</th>\n",
67
+ " <th>no_of_week_nights</th>\n",
68
+ " <th>type_of_meal_plan</th>\n",
69
+ " <th>required_car_parking_space</th>\n",
70
+ " <th>room_type_reserved</th>\n",
71
+ " <th>lead_time</th>\n",
72
+ " <th>arrival_year</th>\n",
73
+ " <th>arrival_month</th>\n",
74
+ " <th>arrival_date</th>\n",
75
+ " <th>market_segment_type</th>\n",
76
+ " <th>repeated_guest</th>\n",
77
+ " <th>no_of_previous_cancellations</th>\n",
78
+ " <th>no_of_previous_bookings_not_canceled</th>\n",
79
+ " <th>avg_price_per_room</th>\n",
80
+ " <th>no_of_special_requests</th>\n",
81
+ " </tr>\n",
82
+ " </thead>\n",
83
+ " <tbody>\n",
84
+ " <tr>\n",
85
+ " <th>0</th>\n",
86
+ " <td>INN70000</td>\n",
87
+ " <td>4</td>\n",
88
+ " <td>10</td>\n",
89
+ " <td>6</td>\n",
90
+ " <td>15</td>\n",
91
+ " <td>Meal Plan 2</td>\n",
92
+ " <td>1</td>\n",
93
+ " <td>Room_Type 6</td>\n",
94
+ " <td>280</td>\n",
95
+ " <td>2017</td>\n",
96
+ " <td>10</td>\n",
97
+ " <td>7</td>\n",
98
+ " <td>Online</td>\n",
99
+ " <td>1</td>\n",
100
+ " <td>13</td>\n",
101
+ " <td>47</td>\n",
102
+ " <td>137.25</td>\n",
103
+ " <td>5</td>\n",
104
+ " </tr>\n",
105
+ " </tbody>\n",
106
+ "</table>\n",
107
+ "</div>"
108
+ ],
109
+ "text/plain": [
110
+ " Booking_ID no_of_adults no_of_children no_of_weekend_nights \\\n",
111
+ "0 INN70000 4 10 6 \n",
112
+ "\n",
113
+ " no_of_week_nights type_of_meal_plan required_car_parking_space \\\n",
114
+ "0 15 Meal Plan 2 1 \n",
115
+ "\n",
116
+ " room_type_reserved lead_time arrival_year arrival_month arrival_date \\\n",
117
+ "0 Room_Type 6 280 2017 10 7 \n",
118
+ "\n",
119
+ " market_segment_type repeated_guest no_of_previous_cancellations \\\n",
120
+ "0 Online 1 13 \n",
121
+ "\n",
122
+ " no_of_previous_bookings_not_canceled avg_price_per_room \\\n",
123
+ "0 47 137.25 \n",
124
+ "\n",
125
+ " no_of_special_requests \n",
126
+ "0 5 "
127
+ ]
128
+ },
129
+ "execution_count": 6,
130
+ "metadata": {},
131
+ "output_type": "execute_result"
132
+ }
133
+ ],
134
+ "source": [
135
+ "# Creating new data as prediction\n",
136
+ "df_inf= {\n",
137
+ " 'Booking_ID':'INN70000', \n",
138
+ " 'no_of_adults':4 , \n",
139
+ " 'no_of_children': 10, \n",
140
+ " 'no_of_weekend_nights':6,\n",
141
+ " 'no_of_week_nights':15, \n",
142
+ " 'type_of_meal_plan':'Meal Plan 2', \n",
143
+ " 'required_car_parking_space': 1,\n",
144
+ " 'room_type_reserved':'Room_Type 6', \n",
145
+ " 'lead_time':280, \n",
146
+ " 'arrival_year': 2017, \n",
147
+ " 'arrival_month':10,\n",
148
+ " 'arrival_date':7, \n",
149
+ " 'market_segment_type':'Online', \n",
150
+ " 'repeated_guest':1,\n",
151
+ " 'no_of_previous_cancellations':13, \n",
152
+ " 'no_of_previous_bookings_not_canceled':47,\n",
153
+ " 'avg_price_per_room':137.25, \n",
154
+ " 'no_of_special_requests':5, \n",
155
+ " \n",
156
+ "}\n",
157
+ "df_inf = pd.DataFrame([df_inf])\n",
158
+ "df_inf"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "code",
163
+ "execution_count": 7,
164
+ "metadata": {},
165
+ "outputs": [
166
+ {
167
+ "name": "stdout",
168
+ "output_type": "stream",
169
+ "text": [
170
+ "This Visitor Predicted: 1\n"
171
+ ]
172
+ }
173
+ ],
174
+ "source": [
175
+ "# Predict new data visitor\n",
176
+ "prediction = best_params.predict(df_inf)\n",
177
+ "print('This Visitor Predicted:', round(prediction[0],2))\n"
178
+ ]
179
+ }
180
+ ],
181
+ "metadata": {
182
+ "kernelspec": {
183
+ "display_name": "base",
184
+ "language": "python",
185
+ "name": "python3"
186
+ },
187
+ "language_info": {
188
+ "codemirror_mode": {
189
+ "name": "ipython",
190
+ "version": 3
191
+ },
192
+ "file_extension": ".py",
193
+ "mimetype": "text/x-python",
194
+ "name": "python",
195
+ "nbconvert_exporter": "python",
196
+ "pygments_lexer": "ipython3",
197
+ "version": "3.11.5"
198
+ }
199
+ },
200
+ "nbformat": 4,
201
+ "nbformat_minor": 2
202
+ }