o  i @sPddlmZddlmZddlmZddlmZddlm Z GdddeZ dS) ) annotations)Callable)IgniteMetricHandler)AveragePrecisionMetric)Averagecs.eZdZdZejddfd fd d ZZS) AveragePrecisionaT Computes Average Precision (AP). accumulating predictions and the ground-truth during an epoch and applying `compute_average_precision`. Args: average: {``"macro"``, ``"weighted"``, ``"micro"``, ``"none"``} Type of averaging performed if not binary classification. Defaults to ``"macro"``. - ``"macro"``: calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account. - ``"weighted"``: calculate metrics for each label, and find their average, weighted by support (the number of true instances for each label). - ``"micro"``: calculate metrics globally by considering each element of the label indicator matrix as a label. - ``"none"``: the scores for each class are returned. output_transform: callable to extract `y_pred` and `y` from `ignite.engine.state.output` then construct `(y_pred, y)` pair, where `y_pred` and `y` can be `batch-first` Tensors or lists of `channel-first` Tensors. the form of `(y_pred, y)` is required by the `update()`. `engine.state` and `output_transform` inherit from the ignite concept: https://pytorch.org/ignite/concepts.html#state, explanation and usage example are in the tutorial: https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb. Note: Average Precision expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or confidence values. cCs|S)N)xrrb/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/handlers/average_precision.py3szAveragePrecision.average Average | stroutput_transformrreturnNonecs$tt|d}tj||dddS)N)r F) metric_fnrZ save_details)rrsuper__init__)selfr rr __class__rr r3szAveragePrecision.__init__)r r rrrr)__name__ __module__ __qualname____doc__rMACROr __classcell__rrrr rs"rN) __future__rcollections.abcrZmonai.handlers.ignite_metricr monai.metricsr monai.utilsrrrrrr s