Skip to content

Commit 0d4bd70

Browse files
committed
ready to deploy
0 parents  commit 0d4bd70

9 files changed

+84
-0
lines changed

app.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from flask import Flask, render_template, redirect, url_for, request, make_response, jsonify
2+
from sklearn.externals import joblib
3+
import numpy as np
4+
import requests
5+
import json
6+
7+
app = Flask(__name__)
8+
9+
10+
@app.route("/")
11+
def index():
12+
return render_template("index.html")
13+
14+
@app.route("/predict", methods=['POST'])
15+
def predict():
16+
if request.method=='POST':
17+
18+
regressor = joblib.load("linear_regression_model.pkl")
19+
20+
data = dict(request.form.items())
21+
22+
years_of_experience = np.array(float(data["YearsExperience"])).reshape(-1,1)
23+
24+
prediction = regressor.predict(years_of_experience)
25+
26+
return render_template("predicted.html", prediction=prediction)
27+
28+
29+
if __name__ == '__main__':
30+
app.run(debug=True)

linear_regression_model.pkl

593 Bytes
Binary file not shown.

prediction.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import requests
2+
BASE_URL = "http://127.0.0.1:5000"
3+
years_exp = {"YearsExperience": 8}
4+
response = requests.post("{}/predict".format(BASE_URL), json = years_exp)
5+
6+
print(response.json())

requirements.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
certifi==2019.11.28
2+
chardet==3.0.4
3+
Click==7.0
4+
Flask==1.1.1
5+
idna==2.8
6+
itsdangerous==1.1.0
7+
Jinja2==2.10.3
8+
joblib==0.14.1
9+
MarkupSafe==1.1.1
10+
numpy==1.17.4
11+
requests==2.22.0
12+
scikit-learn==0.22
13+
scipy==1.4.0
14+
sklearn==0.0
15+
urllib3==1.25.7
16+
Werkzeug==0.16.0

static/animations.js

Whitespace-only changes.

static/style.css

Whitespace-only changes.

templates/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% extends "layout.html" %}
2+
{% block content %}
3+
<!--Enter Name -->
4+
<div style="padding:10px;">
5+
<div class="enter-name">
6+
<form action="{{ url_for('predict') }}" method="POST">
7+
<label>Année d'expérience</label>
8+
<input type="integer" name="YearsExperience" autofocus>
9+
<input type="submit" value="Let's predict salary!">
10+
</form>
11+
</div>
12+
</div>
13+
{% endblock %}

templates/layout.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>ML Project</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
</head>
7+
<body>
8+
{% block content %}{% endblock %}
9+
</body>
10+
</html>

templates/predicted.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "layout.html" %}
2+
{% block content %}
3+
<!--Enter Name -->
4+
<div class="enter-name">
5+
<span>Voici le salaire prédit
6+
<h1> {{ prediction| float }}</h1>
7+
</span>
8+
</div>
9+
{% endblock %}

0 commit comments

Comments
 (0)