add the API
Browse files- app.py +38 -0
- notebook.ipynb +0 -0
- scaling.pkl +0 -0
- templates/home.html +11 -0
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
from flask import Flask , request, jsonify, redirect, render_template
|
3 |
+
import pandas as pd , numpy as np
|
4 |
+
|
5 |
+
app=Flask(__name__)
|
6 |
+
## load the model
|
7 |
+
model = pickle.load(open('regression_model.pkl', 'rb'))
|
8 |
+
scaling = pickle.load(open('scaling.pkl', 'rb'))
|
9 |
+
|
10 |
+
|
11 |
+
@app.route('/')
|
12 |
+
def home():
|
13 |
+
return render_template('home.html')
|
14 |
+
|
15 |
+
|
16 |
+
@app.route('/predict_api', methods = ['POST'])
|
17 |
+
def predict_api():
|
18 |
+
data = request.json['data']
|
19 |
+
data = np.array(list(data.values())).reshape(1,-1)
|
20 |
+
# data = list(np.array(data.values()))
|
21 |
+
new_data = scaling.transform(data)
|
22 |
+
output = model.predict(new_data)
|
23 |
+
return jsonify(output[0])
|
24 |
+
|
25 |
+
# @app.route('/predict')
|
26 |
+
# def predict():
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
app.run(debug=True)
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|
notebook.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
scaling.pkl
ADDED
Binary file (938 Bytes). View file
|
|
templates/home.html
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Document</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>Hello bhai </h1>
|
10 |
+
</body>
|
11 |
+
</html>
|