File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -152,27 +152,32 @@ def tokens_to_vector(tokens, label):
152
152
153
153
154
154
# check misclassified examples
155
+ preds = model .predict (X )
155
156
P = model .predict_proba (X )[:,1 ] # p(y = 1 | x)
156
157
157
158
# since there are many, just print the "most" wrong samples
158
159
minP_whenYis1 = 1
159
160
maxP_whenYis0 = 0
160
161
wrong_positive_review = None
161
162
wrong_negative_review = None
163
+ wrong_positive_prediction = None
164
+ wrong_negative_prediction = None
162
165
for i in range (N ):
163
166
p = P [i ]
164
167
y = Y [i ]
165
168
if y == 1 and p < 0.5 :
166
169
if p < minP_whenYis1 :
167
170
wrong_positive_review = orig_reviews [i ]
171
+ wrong_positive_prediction = preds [i ]
168
172
minP_whenYis1 = p
169
173
elif y == 0 and p > 0.5 :
170
174
if p > maxP_whenYis0 :
171
175
wrong_negative_review = orig_reviews [i ]
176
+ wrong_negative_prediction = preds [i ]
172
177
maxP_whenYis0 = p
173
178
174
- print ("Most wrong positive review (prob = %s):" % minP_whenYis1 )
179
+ print ("Most wrong positive review (prob = %s, pred = %s ):" % ( minP_whenYis1 , wrong_positive_prediction ) )
175
180
print (wrong_positive_review )
176
- print ("Most wrong negative review (prob = %s):" % maxP_whenYis0 )
181
+ print ("Most wrong negative review (prob = %s, pred = %s ):" % ( maxP_whenYis0 , wrong_negative_prediction ) )
177
182
print (wrong_negative_review )
178
183
You can’t perform that action at this time.
0 commit comments