-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
54 lines (49 loc) · 1.71 KB
/
Copy pathapp.py
File metadata and controls
54 lines (49 loc) · 1.71 KB
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
from flask import Flask, redirect, url_for, render_template, request, session
import json
import sys
import os
import features_module as fm
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def home_route():
dict={}
if request.method == 'GET':
dict['question']=''
dict['refans']=''
dict['studans']=''
dict['result']=''
dict['display']='none'
elif request.method == 'POST':
dict['question']=request.form['question']
dict['refans']=request.form['refans']
dict['studans']=request.form['studans']
dict['display']='block'
f=fm.get_features([request.form['studans']],request.form['refans'],request.form['question'])
x=fm.get_prob(f)[0]
print(x)
p=""
c=''
score=round(x[1]*10,1)
if score>5.5:
p='correct'
c='ag'
elif score>3.0:
p='partially correct'
c='ap'
else:
p='wrong'
c='ar'
dict['result']=p
dict['scoreclass']=c
if score>5.5:
score=score+1;
dict['score']=score
columns = ['prompt_overlap','av_word_len','sent_length','Cosine w2v','Cosine d2v','FSTS','Cosine Elmo','LSA 1','LSA 2','LSA 3','TTR','JC Sim','SP Sim','Cosine USE']
# explainer = shap.TreeExplainer(fm.clf)
# shap_values = explainer.shap_values(f)
# shap.initjs()
# dict['explain']=shap.force_plot(explainer.expected_value[1], shap_values[1], columns)
return render_template('home.html',data=dict)
if __name__ == "__main__":
app.secret_key = os.urandom(12) # Generic key for dev purposes only
app.run(debug=True, use_reloader=True, host='0.0.0.0')