Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
akfaisel authored Feb 17, 2020
1 parent 6674445 commit bb0da45
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn flask_app:flask_app_obj
27 changes: 27 additions & 0 deletions flask_app.py
Original file line number Diff line number Diff line change
@@ -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)
Binary file added model.pkl
Binary file not shown.
11 changes: 11 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>ML API - Salary Prediction</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<form action="{{ url_for('predict')}}" method="post" style="width: 400px;" class="mx-auto">
<h1>Salary Prediction</h1>
<div class="form-group">
<label for="experience">Experience</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-american-sign-language-interpreting"></i>
</div>
</div>
<input id="experience" name="experience" placeholder="Enter experience (0-15)" type="text" required="required" class="form-control">
</div>
</div>
<div class="form-group">
<label for="test_score">Test Score</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-cc-discover"></i>
</div>
</div>
<input id="test_score" name="test_score" placeholder="Enter test score (0-10)" type="text" required="required" class="form-control">
</div>
</div>
<div class="form-group">
<label for="interview_score">Interview Score</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-calculator"></i>
</div>
</div>
<input id="interview_score" name="interview_score" placeholder="Enter interview score (0-10)" type="text" required="required" class="form-control">
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Predict</button>
</div>
</form>


<br>
<br>
<div class="mx-auto" style="width: 400px;">{{ prediction_text }}</div>
</body>
</html>

0 comments on commit bb0da45

Please sign in to comment.