-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKNNDeploy.py
51 lines (42 loc) · 1.17 KB
/
KNNDeploy.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
from flask import Flask,jsonify,request
from flasgger import Swagger
from sklearn.externals import joblib
import numpy as np
from flask_cors import CORS
import pandas
#import iki ra nemu nang requirements.txtne mesti raono
app = Flask(__name__)
Swagger(app)
CORS(app)
@app.route('/input/task', methods=['POST'])
def predict():
"""
Ini Adalah Endpoint Untuk Mengalasisa Sentiment dari kalimat tweet yang dimasukan
---
tags:
- Rest Controller
parameters:
- name: body
in: body
required: true
schema:
id: Sentence
required:
- textSentence
properties:
textSentence:
type: string
description: Please input with valid text.
default: 0
responses:
200:
description: Success Input
"""
new_task = request.get_json()
textSentence = new_task['textSentence']
X_New = np.array([textSentence])
pipe = joblib.load('BOHEMIANRHAPSODY-SENTIMENTANALYSIS.pkl')
resultPredict = pipe[0].predict(X_New)
return jsonify({'message': format(resultPredict)})
if __name__ == '__main__' :
app.run(debug=True)