-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (24 loc) · 667 Bytes
/
Copy pathapp.py
File metadata and controls
32 lines (24 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, request
from json import loads
import numpy as np
from sklearn.linear_model import LinearRegression
with open('model.json', 'r') as f:
content = f.read()
model = loads(content)
predictor = LinearRegression(n_jobs=-1)
predictor.coef_ = np.array(model)
predictor.intercept_ = np.array([0])
app = Flask(__name__)
@app.route('/')
def hello_world():
params = request.args.get('input') # "10,20,30"
parameters = params.split(",")
X = [[
int(parameters[0]),
int(parameters[1]),
int(parameters[2])
]]
outcome = predictor.predict(X=X)
return str(outcome)
if __name__ == "__main__":
app.run()