-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (20 loc) · 740 Bytes
/
app.py
File metadata and controls
28 lines (20 loc) · 740 Bytes
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
import numpy as np
import pickle
from flask import Flask, request, jsonify
app = Flask(__name__)
# Predict using the model
@app.route('/predict', methods=['POST'])
def predict():
# Load the model
model_path = 'model/rental_prediction_model.pkl'
model = pickle.load(open(model_path, 'rb'))
user_input = request.json
rooms = int(user_input.get('rooms',0))
area = int(user_input.get('area',0))
user_input_preprocessed = np.array([[rooms, area]])
# Make a prediction
prediction = model.predict(user_input_preprocessed)
output = {"Rental Prediction using Built Model V2": float(prediction[0])}
return output
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)