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 0000000..f99758b Binary files /dev/null and b/model.pkl differ 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 }}
+ +