From bb0da4525bfa54a4e1f1495b553ec8b215fbd751 Mon Sep 17 00:00:00 2001 From: akfaisel Date: Mon, 17 Feb 2020 14:46:50 +0530 Subject: [PATCH] Add files via upload --- Procfile | 1 + flask_app.py | 27 +++++++++++++++++++++ model.pkl | Bin 0 -> 547 bytes requirements.txt | 11 +++++++++ templates/form.html | 56 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 Procfile create mode 100644 flask_app.py create mode 100644 model.pkl create mode 100644 requirements.txt create mode 100644 templates/form.html diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ab7cb88 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn flask_app:flask_app_obj \ No newline at end of file diff --git a/flask_app.py b/flask_app.py new file mode 100644 index 0000000..df8fa4c --- /dev/null +++ b/flask_app.py @@ -0,0 +1,27 @@ +import numpy as np +from flask import Flask, request, jsonify, render_template +import pickle + +flask_app_obj = Flask(__name__) +model = pickle.load(open('model.pkl', 'rb')) + +@flask_app_obj.route('/') +def home(): + return render_template('form.html') + +@flask_app_obj.route('/predict',methods=['POST']) +def predict(): + ''' + For rendering results on HTML GUI + ''' + int_features = [int(x) for x in request.form.values()] + final_features = [np.array(int_features)] + prediction = model.predict(final_features) + + output = round(prediction[0], 2) + + return render_template('form.html', prediction_text='Employee Salary should be Rs. {}'.format(output)) + + +if __name__ == "__main__": + flask_app_obj.run(debug=True) \ No newline at end of file diff --git a/model.pkl b/model.pkl new file mode 100644 index 0000000000000000000000000000000000000000..f99758b4deea6ca5a3f84925d3e0261e1f6537f8 GIT binary patch literal 547 zcmZ{hzi-n(9L4RXEs3F!ra;SYN}(i+3!NAcGNcm*50;QTRGe(*TAMm&zq>P1S|LDH z(^i#OSzzcu|A%huNEIL zZhFH?2-B=XJPd6VH%1<%fxxii4HY%IKyWBzc{}TvValo5&J!8?ockSva2lpeNS=q% zK>47{V6B5HDz>%;qp1ftypAI-M(Vb1m)3B!-`J9!j2bxR4fI%VplWNjzK&5BwYpvM zbfwN?e_p+NdK;&@IPKz0;h+0#iQufF>3yAu*{rJga%6k!`UZix*oSikVqmc*ZKGEE_H2?qr literal 0 HcmV?d00001 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e8071de --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +Flask==1.1.1 +gunicorn==19.9.0 +itsdangerous==1.1.0 +Jinja2==2.10.1 +MarkupSafe==1.1.1 +Werkzeug==0.15.5 +numpy>=1.9.2 +scipy>=0.15.1 +scikit-learn>=0.18 +matplotlib>=1.4.3 +pandas>=0.19 \ No newline at end of file diff --git a/templates/form.html b/templates/form.html new file mode 100644 index 0000000..9383590 --- /dev/null +++ b/templates/form.html @@ -0,0 +1,56 @@ + + + + + + ML API - Salary Prediction + + + + +
+

Salary Prediction

+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ + +
+
+
{{ prediction_text }}
+ +