Download pt_variety_identifier/src/bert/results.py from LCA-PORVID/code: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/LCA-PORVID/code/resolve/main/pt_variety_identifier/src/bert/results.py
- Command line
-
hf download hf://LCA-PORVID/code/pt_variety_identifier/src/bert/results.py
-
curl -L -o results.py https://huggingface.co/LCA-PORVID/code/resolve/main/pt_variety_identifier/src/bert/results.py
1.36 kB
| from pt_variety_identifier.src.results import Results as BaseResults | |
| import logging | |
| class Results(BaseResults): | |
| def __init__(self, filepath, DOMAINS) -> None: | |
| super().__init__(filepath, DOMAINS) | |
| def process(self, cross_domain_f1, train_domain, test_results, train_results, balance, pos_prob, ner_prob): | |
| if cross_domain_f1 > self.best_f1_scores[train_domain]["cross_domain_f1"]: | |
| logging.info(f"New best f1 score for {train_domain}") | |
| self.best_f1_scores[train_domain]["cross_domain_f1"] = cross_domain_f1 | |
| self.best_f1_scores[train_domain]["test_results"] = test_results | |
| self.best_f1_scores[train_domain]["balance"] = balance | |
| self.best_f1_scores[train_domain]["pos_prob"] = pos_prob | |
| self.best_f1_scores[train_domain]["ner_prob"] = ner_prob | |
| logging.info( | |
| f"Saving best cross_domain_f1 scores to file") | |
| self.best_final_results() | |
| #TODO: Save PyTorch model | |
| self.best_intermediate_results({ | |
| "domain": train_domain, | |
| "balance": balance, | |
| "pos_prob": pos_prob, | |
| "ner_prob": ner_prob, | |
| "train": train_results, | |
| "test": { | |
| 'all': test_results, | |
| 'cross_domain_f1': cross_domain_f1 | |
| } | |
| }) |