Update qbmodel.py
Browse files- qbmodel.py +13 -1
qbmodel.py
CHANGED
|
@@ -170,7 +170,7 @@ class QuizBowlModel:
|
|
| 170 |
#max_confidence, max_answer = selected_model.predict(input_data)
|
| 171 |
#print("Prediction for category", self.categories[category], ":", max_answer, "with confidence", max_confidence)
|
| 172 |
|
| 173 |
-
return (np.tanh(max_confidence), max_answer)
|
| 174 |
|
| 175 |
def evaluate(self, input_data):
|
| 176 |
correct = 0
|
|
@@ -199,6 +199,18 @@ class QuizBowlModel:
|
|
| 199 |
accuracy = correct/len(input_data)
|
| 200 |
|
| 201 |
return accuracy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
|
| 204 |
|
|
|
|
| 170 |
#max_confidence, max_answer = selected_model.predict(input_data)
|
| 171 |
#print("Prediction for category", self.categories[category], ":", max_answer, "with confidence", max_confidence)
|
| 172 |
|
| 173 |
+
return (self.confidence_eq(np.tanh(max_confidence)), max_answer)
|
| 174 |
|
| 175 |
def evaluate(self, input_data):
|
| 176 |
correct = 0
|
|
|
|
| 199 |
accuracy = correct/len(input_data)
|
| 200 |
|
| 201 |
return accuracy
|
| 202 |
+
|
| 203 |
+
def confidence_eq(self,x):
|
| 204 |
+
|
| 205 |
+
if(x < 0.5):
|
| 206 |
+
return 0
|
| 207 |
+
elif(x < 0.6):
|
| 208 |
+
return 2*x - 1
|
| 209 |
+
elif(x < 0.7):
|
| 210 |
+
return 4*x - 2.2
|
| 211 |
+
else:
|
| 212 |
+
return min(1, 1.5*(x + 0.1)**2 - 0.36)
|
| 213 |
+
|
| 214 |
|
| 215 |
|
| 216 |
|