-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote_flasgger.py
81 lines (65 loc) · 1.93 KB
/
note_flasgger.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from flask import Flask,request
import pandas as pd
import numpy as np
import pickle
import flasgger
from flasgger import Swagger
app=Flask(__name__) #the point we need to start the application
Swagger(app)
pickle_in = open('classifier.pkl','rb') #read-only in birany format
classifier = pickle.load(pickle_in)
@app.route('/') #route path
def welcome():
return "Welcome All"
@app.route('/predict',methods=['Get']) #default get methods
def predit_note_authentication():
"""Let's Authenticate the Banks Note
This is using docstrings for specifications.
---
parameters:
- name: variance
in: query
type: number
required: true
- name: skewness
in: query
type: number
required: true
- name: curtosis
in: query
type: number
required: true
- name: entropy
in: query
type: number
required: true
responses:
200:
description: The output values
"""
variance=request.args.get('variance')
skewness=request.args.get('skewness')
curtosis=request.args.get('curtosis')
entropy=request.args.get('entropy')
prediction = classifier.predict([[variance,skewness,curtosis,entropy]])
return "The predicted value is"+ str(prediction)
@app.route('/predict_file',methods=["POST"])
def predit_note_file():
"""Let's Authenticate the Banks Note
This is using docstrings for specifications.
---
parameters:
- name: file
in: formData
type: file
required: true
responses:
200:
description: The output values
"""
df_test = pd.read_csv(request.files.get("file"))
print(df_test.head())
prediction = classifier.predict(df_test)
return str(list(prediction))
if __name__ == '__main__':
app.run()