-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn flask_app:flask_app_obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |