-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
27 lines (22 loc) · 814 Bytes
/
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
# Importing essential libraries
from flask import Flask, render_template, request
import pickle
# Load the Multinomial Naive Bayes model and CountVectorizer object from disk
filename = 'restaurant-sentiment-mnb-model.pkl'
classifier = pickle.load(open(filename, 'rb'))
cv = pickle.load(open('cv-transform.pkl','rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
if request.method == 'POST':
message = request.form['message']
data = [message]
vect = cv.transform(data).toarray()
my_prediction = classifier.predict(vect)
return render_template('result.html', prediction=my_prediction)
if __name__ == '__main__':
#app.run(host='127.0.0.1', port=8001, debug=True)
app.run(debug=True)