mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	Update Scorer.ents_per_type
This commit is contained in:
		
							parent
							
								
									ebe58e7fa1
								
							
						
					
					
						commit
						8721849423
					
				| 
						 | 
					@ -92,6 +92,15 @@ class Scorer(object):
 | 
				
			||||||
        """RETURNS (float): Named entity accuracy (F-score)."""
 | 
					        """RETURNS (float): Named entity accuracy (F-score)."""
 | 
				
			||||||
        return self.ner.fscore * 100
 | 
					        return self.ner.fscore * 100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @property
 | 
				
			||||||
 | 
					    def ents_per_type(self):
 | 
				
			||||||
 | 
					        """RETURNS (dict): Scores per entity label.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            k: {"p": v.precision * 100, "r": v.recall * 100, "f": v.fscore * 100}
 | 
				
			||||||
 | 
					            for k, v in self.ner_per_ents.items()
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def scores(self):
 | 
					    def scores(self):
 | 
				
			||||||
        """RETURNS (dict): All scores with keys `uas`, `las`, `ents_p`,
 | 
					        """RETURNS (dict): All scores with keys `uas`, `las`, `ents_p`,
 | 
				
			||||||
| 
						 | 
					@ -103,17 +112,9 @@ class Scorer(object):
 | 
				
			||||||
            "ents_p": self.ents_p,
 | 
					            "ents_p": self.ents_p,
 | 
				
			||||||
            "ents_r": self.ents_r,
 | 
					            "ents_r": self.ents_r,
 | 
				
			||||||
            "ents_f": self.ents_f,
 | 
					            "ents_f": self.ents_f,
 | 
				
			||||||
 | 
					            "ents_per_type": self.ents_per_type,
 | 
				
			||||||
            "tags_acc": self.tags_acc,
 | 
					            "tags_acc": self.tags_acc,
 | 
				
			||||||
            "token_acc": self.token_acc,
 | 
					            "token_acc": self.token_acc,
 | 
				
			||||||
            "ents_per_type": self.__scores_per_ents(),
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def __scores_per_ents(self):
 | 
					 | 
				
			||||||
        """RETURNS (dict): Scores per NER entity
 | 
					 | 
				
			||||||
        """
 | 
					 | 
				
			||||||
        return {
 | 
					 | 
				
			||||||
            k: {"p": v.precision * 100, "r": v.recall * 100, "f": v.fscore * 100}
 | 
					 | 
				
			||||||
            for k, v in self.ner_per_ents.items()
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def score(self, doc, gold, verbose=False, punct_labels=("p", "punct")):
 | 
					    def score(self, doc, gold, verbose=False, punct_labels=("p", "punct")):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ Update the evaluation scores from a single [`Doc`](/api/doc) /
 | 
				
			||||||
## Properties
 | 
					## Properties
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| Name                                           | Type  | Description                                                                                                   |
 | 
					| Name                                           | Type  | Description                                                                                                   |
 | 
				
			||||||
| ----------- | ----- | -------------------------------------------------------------------------------------------- |
 | 
					| ---------------------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------- |
 | 
				
			||||||
| `token_acc`                                    | float | Tokenization accuracy.                                                                                        |
 | 
					| `token_acc`                                    | float | Tokenization accuracy.                                                                                        |
 | 
				
			||||||
| `tags_acc`                                     | float | Part-of-speech tag accuracy (fine grained tags, i.e. `Token.tag`).                                            |
 | 
					| `tags_acc`                                     | float | Part-of-speech tag accuracy (fine grained tags, i.e. `Token.tag`).                                            |
 | 
				
			||||||
| `uas`                                          | float | Unlabelled dependency score.                                                                                  |
 | 
					| `uas`                                          | float | Unlabelled dependency score.                                                                                  |
 | 
				
			||||||
| 
						 | 
					@ -55,4 +55,5 @@ Update the evaluation scores from a single [`Doc`](/api/doc) /
 | 
				
			||||||
| `ents_p`                                       | float | Named entity accuracy (precision).                                                                            |
 | 
					| `ents_p`                                       | float | Named entity accuracy (precision).                                                                            |
 | 
				
			||||||
| `ents_r`                                       | float | Named entity accuracy (recall).                                                                               |
 | 
					| `ents_r`                                       | float | Named entity accuracy (recall).                                                                               |
 | 
				
			||||||
| `ents_f`                                       | float | Named entity accuracy (F-score).                                                                              |
 | 
					| `ents_f`                                       | float | Named entity accuracy (F-score).                                                                              |
 | 
				
			||||||
| `scores`    | dict  | All scores with keys `uas`, `las`, `ents_p`, `ents_r`, `ents_f`, `tags_acc` and `token_acc`. |
 | 
					| `ents_per_type` <Tag variant="new">2.1.5</Tag> | dict  | Scores per entity label. Keyed by label, mapped to a dict of `p`, `r` and `f` scores.                         |
 | 
				
			||||||
 | 
					| `scores`                                       | dict  | All scores with keys `uas`, `las`, `ents_p`, `ents_r`, `ents_f`, `ents_per_type`, `tags_acc` and `token_acc`. |
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user