JRQi commited on
Commit
3a10092
β€’
1 Parent(s): 1b0b123

Update game3.py

Browse files
Files changed (1) hide show
  1. game3.py +12 -16
game3.py CHANGED
@@ -40,9 +40,9 @@ def func3(num_selected, human_predict, num1, num2, user_important):
40
  interpretation = eval(content[int(num_selected*2+1)])
41
 
42
  if text['binary_label'] == 1:
43
- golden_label = int(50 * (1 - text['binary_score']))
44
  else:
45
- golden_label = int(50 * (1 + text['binary_score']))
46
 
47
  # (START) off-the-shelf version -- slow at the beginning
48
  # Load model directly
@@ -58,9 +58,9 @@ def func3(num_selected, human_predict, num1, num2, user_important):
58
  # (END) off-the-shelf version
59
 
60
  if out['label'] == 'Female':
61
- ai_predict = int(100 * out['score'])
62
  else:
63
- ai_predict = 100 - int(100 * out['score'])
64
 
65
  user_select = "You focused on "
66
  flag_select = False
@@ -80,20 +80,20 @@ def func3(num_selected, human_predict, num1, num2, user_important):
80
  # user_select += "nothing. Interesting! "
81
  user_select += "Wanna see how the AI made the guess? Click here. ⬅️"
82
 
83
- if golden_label > 60:
84
  gender = ' (female)'
85
- elif golden_label < 40:
86
  gender = ' (male)'
87
  else:
88
  gender = ' (neutral)'
89
 
90
- if abs(golden_label - human_predict) <= 20 and abs(golden_label - ai_predict) <= 20:
91
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Congratulations! πŸŽ‰ Both of you get the correct answer!", user_select))
92
  num1 += 1
93
  num2 += 1
94
- elif abs(golden_label - human_predict) > 20 and abs(golden_label - ai_predict) > 20:
95
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Sorry.. No one gets the correct answer. But nice try! πŸ˜‰", user_select))
96
- elif abs(golden_label - human_predict) <= 20 and abs(golden_label - ai_predict) > 20:
97
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Great! πŸŽ‰ You are closer to the answer and better than AI!", user_select))
98
  num1 += 1
99
  else:
@@ -102,10 +102,6 @@ def func3(num_selected, human_predict, num1, num2, user_important):
102
 
103
  tot_scores = ''' ### <p style="text-align: center;"> πŸ€– Machine &ensp; ''' + str(int(num2)) + ''' &ensp; VS &ensp; ''' + str(int(num1)) + ''' &ensp; Human πŸ‘¨πŸ‘© </p>'''
104
 
105
-
106
- num_tmp = max(num1, num2)
107
- y_lim_upper = (int((num_tmp + 3)/10)+1) * 10
108
-
109
  return ai_predict, chatbot, num1, num2, tot_scores
110
 
111
  def interpre3(num_selected):
@@ -165,11 +161,11 @@ def func3_written(text_written, human_predict, lang_written):
165
  # (END) off-the-shelf version
166
 
167
  if out['label'] == 'Female':
168
- ai_predict = int(100 * out['score'])
169
  else:
170
- ai_predict = 100 - int(100 * out['score'])
171
 
172
- if abs(ai_predict - human_predict) <= 20:
173
  chatbot.append(("AI gives it a close score! πŸŽ‰", "⬅️ Feel free to try another one! ⬅️"))
174
  else:
175
  chatbot.append(("AI thinks in a different way from human. πŸ˜‰", "⬅️ Feel free to try another one! ⬅️"))
 
40
  interpretation = eval(content[int(num_selected*2+1)])
41
 
42
  if text['binary_label'] == 1:
43
+ golden_label = int(5 * (1 - text['binary_score']))
44
  else:
45
+ golden_label = int(5 * (1 + text['binary_score']))
46
 
47
  # (START) off-the-shelf version -- slow at the beginning
48
  # Load model directly
 
58
  # (END) off-the-shelf version
59
 
60
  if out['label'] == 'Female':
61
+ ai_predict = int(10 * out['score'])
62
  else:
63
+ ai_predict = 10 - int(10 * out['score'])
64
 
65
  user_select = "You focused on "
66
  flag_select = False
 
80
  # user_select += "nothing. Interesting! "
81
  user_select += "Wanna see how the AI made the guess? Click here. ⬅️"
82
 
83
+ if golden_label > 6:
84
  gender = ' (female)'
85
+ elif golden_label < 4:
86
  gender = ' (male)'
87
  else:
88
  gender = ' (neutral)'
89
 
90
+ if abs(golden_label - human_predict) <= 2 and abs(golden_label - ai_predict) <= 2:
91
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Congratulations! πŸŽ‰ Both of you get the correct answer!", user_select))
92
  num1 += 1
93
  num2 += 1
94
+ elif abs(golden_label - human_predict) > 2 and abs(golden_label - ai_predict) > 2:
95
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Sorry.. No one gets the correct answer. But nice try! πŸ˜‰", user_select))
96
+ elif abs(golden_label - human_predict) <= 2 and abs(golden_label - ai_predict) > 2:
97
  chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Great! πŸŽ‰ You are closer to the answer and better than AI!", user_select))
98
  num1 += 1
99
  else:
 
102
 
103
  tot_scores = ''' ### <p style="text-align: center;"> πŸ€– Machine &ensp; ''' + str(int(num2)) + ''' &ensp; VS &ensp; ''' + str(int(num1)) + ''' &ensp; Human πŸ‘¨πŸ‘© </p>'''
104
 
 
 
 
 
105
  return ai_predict, chatbot, num1, num2, tot_scores
106
 
107
  def interpre3(num_selected):
 
161
  # (END) off-the-shelf version
162
 
163
  if out['label'] == 'Female':
164
+ ai_predict = int(10 * out['score'])
165
  else:
166
+ ai_predict = 10 - int(10 * out['score'])
167
 
168
+ if abs(ai_predict - human_predict) <= 2:
169
  chatbot.append(("AI gives it a close score! πŸŽ‰", "⬅️ Feel free to try another one! ⬅️"))
170
  else:
171
  chatbot.append(("AI thinks in a different way from human. πŸ˜‰", "⬅️ Feel free to try another one! ⬅️"))