forked from OmkarNallagoni/Linear_regression
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
65 lines (47 loc) · 1.74 KB
/
app.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Created on Fri Nov 14 2019
@author: Omkar Nallagoni
"""
import numpy as np
import pickle
import pandas as pd
from flask import Flask, request
#model.pkl is used to get the predictions on new data
# in this page np pd pickle we did not used it is masked
# yellow error
app=Flask(__name__)
pickle_in = open("model.pkl","rb")
classifier=pickle.load(pickle_in)
@app.route('/') # decorator
def welcome():
return "Welcome All"
@app.route('/predict',methods=["Get"])
def predict_note_authentication():
"""
['MedInc','HouseAge','AveRooms','AveBedrms','Population','AveOccup','Latitude','Longitude'
"""
input_cols= ['MedInc','HouseAge','AveRooms','AveBedrms','Population','AveOccup','Latitude','Longitude']
list1=[]
for i in input_cols:
val=request.args.get(i)
list1.append(eval(val))
'''
MedInc=request.args.get("MedInc")
HouseAge=request.args.get("HouseAge")
AveRooms=request.args.get("AveRooms")
AveBedrms=request.args.get("AveBedrms")
Population=request.args.get("Population")
AveOccup=request.args.get("AveOccup")
Latitude=request.args.get("Latitude")
Longitude=request.args.get("Longitude")'''
prediction=classifier.predict([list1])
#prediction=classifier.predict([[variance,skewness,curtosis,entropy]])
print(prediction)
return "Hello The answer is"+str(prediction)
@app.route('/predict_file',methods=["POST"])
def predict_note_file():
df_test=pd.read_csv(request.files.get("file")) # whatever name you written here the same name will provide in Post man
prediction=classifier.predict(df_test)
return str(list(prediction))
if __name__=='__main__':
app.run(host='0.0.0.0',port=8000)