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):
152152
153153
154154# check misclassified examples
155+ preds = model .predict (X )
155156P = model .predict_proba (X )[:,1 ] # p(y = 1 | x)
156157
157158# since there are many, just print the "most" wrong samples
158159minP_whenYis1 = 1
159160maxP_whenYis0 = 0
160161wrong_positive_review = None
161162wrong_negative_review = None
163+ wrong_positive_prediction = None
164+ wrong_negative_prediction = None
162165for i in range (N ):
163166 p = P [i ]
164167 y = Y [i ]
165168 if y == 1 and p < 0.5 :
166169 if p < minP_whenYis1 :
167170 wrong_positive_review = orig_reviews [i ]
171+ wrong_positive_prediction = preds [i ]
168172 minP_whenYis1 = p
169173 elif y == 0 and p > 0.5 :
170174 if p > maxP_whenYis0 :
171175 wrong_negative_review = orig_reviews [i ]
176+ wrong_negative_prediction = preds [i ]
172177 maxP_whenYis0 = p
173178
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 ) )
175180print (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 ) )
177182print (wrong_negative_review )
178183
You can’t perform that action at this time.
0 commit comments