-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
37 lines (25 loc) · 1.38 KB
/
application.py
File metadata and controls
37 lines (25 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import joblib
import numpy as np
from config.paths_config import MODEL_OUTPUT_PATH
from flask import Flask, render_template,request
app = Flask(__name__)
loaded_model = joblib.load(MODEL_OUTPUT_PATH)
@app.route('/',methods=['GET','POST'])
def index():
if request.method=='POST':
lead_time = int(request.form["lead_time"])
no_of_special_request = int(request.form["no_of_special_request"])
avg_price_per_room = float(request.form["avg_price_per_room"])
arrival_month = int(request.form["arrival_month"])
arrival_date = int(request.form["arrival_date"])
market_segment_type = int(request.form["market_segment_type"])
no_of_week_nights = int(request.form["no_of_week_nights"])
no_of_weekend_nights = int(request.form["no_of_weekend_nights"])
type_of_meal_plan = int(request.form["type_of_meal_plan"])
room_type_reserved = int(request.form["room_type_reserved"])
features = np.array([[lead_time,no_of_special_request,avg_price_per_room,arrival_month,arrival_date,market_segment_type,no_of_week_nights,no_of_weekend_nights,type_of_meal_plan,room_type_reserved]])
prediction = loaded_model.predict(features)
return render_template('index.html', prediction=prediction[0])
return render_template("index.html" , prediction=None)
if __name__=="__main__":
app.run(host='0.0.0.0' , port=8080)