MCPcopy Create free account
hub / github.com/modelscope/modelscope / get_metrics

Method get_metrics

modelscope/trainers/trainer.py:646–668  ·  view source on GitHub ↗

Get the metric class types. The first choice will be the metrics configured in the config file, if not found, the default metrics will be used. If no metrics is found and the eval dataset exists, the method will raise an error. Returns: The metric types.

(self)

Source from the content-addressed store, hash-verified

644 return train_preprocessor, eval_preprocessor
645
646 def get_metrics(self) -> List[Union[str, Dict]]:
647 """Get the metric class types.
648
649 The first choice will be the metrics configured in the config file, if not found, the default metrics will be
650 used.
651 If no metrics is found and the eval dataset exists, the method will raise an error.
652
653 Returns: The metric types.
654
655 """
656 metrics = self.cfg.evaluation.metrics if hasattr(
657 self.cfg, 'evaluation') and hasattr(self.cfg.evaluation,
658 'metrics') else None
659 metrics = metrics if metrics is not None else task_default_metrics.get(
660 self.cfg.task)
661 if metrics is None and self.eval_dataset is not None:
662 raise ValueError(
663 f'Metrics are needed in evaluation, please try to either '
664 f'add metrics in configuration.json or add the default metric for {self.cfg.task}.'
665 )
666 if isinstance(metrics, (str, Mapping)):
667 metrics = [metrics]
668 return metrics
669
670 def set_checkpoint_file_to_hook(self, checkpoint_path, load_all_state,
671 strict):

Callers 1

__init__Method · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected