mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Fix f-score calculation if zero
This commit is contained in:
		
							parent
							
								
									6b0008afc6
								
							
						
					
					
						commit
						981cb89194
					
				|  | @ -140,7 +140,10 @@ def evaluate(tokenizer, textcat, texts, cats): | ||||||
|                 fn += 1 |                 fn += 1 | ||||||
|     precision = tp / (tp + fp) |     precision = tp / (tp + fp) | ||||||
|     recall = tp / (tp + fn) |     recall = tp / (tp + fn) | ||||||
|     f_score = 2 * (precision * recall) / (precision + recall) |     if (precision+recall) == 0: | ||||||
|  |         f_score = 0.0 | ||||||
|  |     else: | ||||||
|  |         f_score = 2 * (precision * recall) / (precision + recall) | ||||||
|     return {"textcat_p": precision, "textcat_r": recall, "textcat_f": f_score} |     return {"textcat_p": precision, "textcat_r": recall, "textcat_f": f_score} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user