def use_subset(self, subset_def):
        """Restricts the evaluation results to the specified subset.

        Subsequent calls to supported methods on this instance will only
        contain results from the specified subset rather than the full results.

        Use :meth:`clear_subset` to reset to the full results. Or,
        equivalently, use the context manager interface as demonstrated below
        to automatically reset the results when the context exits.

        Example usage::

            import fiftyone as fo
            import fiftyone.zoo as foz
            import fiftyone.utils.random as four
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")
            four.random_split(dataset, {"sunny": 0.7, "cloudy": 0.2, "rainy": 0.1})

            results = dataset.evaluate_detections(
                "predictions",
                gt_field="ground_truth",
                eval_key="eval",
            )

            counts = dataset.count_values("ground_truth.detections.label")
            classes = sorted(counts, key=counts.get, reverse=True)[:5]

            # Full results
            results.print_report(classes=classes)

            # Sunny samples
            subset_def = dict(type="field", field="tags", value="sunny")
            with results.use_subset(subset_def):
                results.print_report(classes=classes)

            # Small objects
            bbox_area = F("bounding_box")[2] * F("bounding_box")[3]
            small_objects = bbox_area <= 0.05
            subset_def = dict(type="attribute", expr=small_objects)
            with results.use_subset(subset_def):
                results.print_report(classes=classes)

        Args:
            subset_def: the subset definition, which can be:

                -   a dict or list of dicts defining the subset. See above
                    for examples and see :func:`get_subset_view` for full
                    syntax
                -   a :class:`fiftyone.core.view.DatasetView` defining the
                    subset

        Returns:
            self
        """
        if self.ytrue_ids is None:
            raise ValueError(
                "Cannot load subsets for evaluation runs that don't store "
                "label IDs"
            )

        gt_field = self.config.gt_field
        if isinstance(subset_def, foc.SampleCollection):
            subset_view = subset_def
        else:
            subset_view = get_subset_view(self.samples, gt_field, subset_def)

        self._samples_orig = self.samples
        self._ytrue_orig = self.ytrue
        self._ypred_orig = self.ypred
        self._confs_orig = self.confs
        self._weights_orig = self.weights
        self._ytrue_ids_orig = self.ytrue_ids
        self._ypred_ids_orig = self.ypred_ids

        # Locate all ground truth in subset
        _, gt_id_path = subset_view._get_label_field_path(gt_field, "id")
        gt_ids = set(subset_view.values(gt_id_path, unwind=True))
        inds = np.array([_id in gt_ids for _id in self.ytrue_ids])

        # Detection evaluations can contain unmatched predictions, which must
        # also be partitioned into subsets
        if isinstance(self, foue.DetectionResults):
            pred_field = self.config.pred_field
            fp_view = subset_view.filter_labels(
                pred_field, F(self.key) == "fp"
            )
            _, pred_id_path = fp_view._get_label_field_path(pred_field, "id")
            pred_ids = set(fp_view.values(pred_id_path, unwind=True))
            inds |= np.array([_id in pred_ids for _id in self.ypred_ids])

        self._has_subset = True
        self._samples = subset_view
        self.ytrue = self.ytrue[inds]
        self.ypred = self.ypred[inds]
        self.confs = self.confs[inds] if self.confs is not None else None
        self.weights = self.weights[inds] if self.weights is not None else None
        self.ytrue_ids = self.ytrue_ids[inds]
        self.ypred_ids = self.ypred_ids[inds]

        return self
Restricts the evaluation results to the specified subset.

        Subsequent calls to supported methods on this instance will only
        contain results from the specified subset rather than the full results.

        Use :meth:`clear_subset` to reset to the full results. Or,
        equivalently, use the context manager interface as demonstrated below
        to automatically reset the results when the context exits.

        Example usage::

            import fiftyone as fo
            import fiftyone.zoo as foz
            import fiftyone.utils.random as four
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")
            four.random_split(dataset, {"sunny": 0.7, "cloudy": 0.2, "rainy": 0.1})

            results = dataset.evaluate_detections(
                "predictions",
                gt_field="ground_truth",
                eval_key="eval",
            )

            counts = dataset.count_values("ground_truth.detections.label")
            classes = sorted(counts, key=counts.get, reverse=True)[:5]

            # Full results
            results.print_report(classes=classes)

            # Sunny samples
            subset_def = dict(type="field", field="tags", value="sunny")
            with results.use_subset(subset_def):
                results.print_report(classes=classes)

            # Small objects
            bbox_area = F("bounding_box")[2] * F("bounding_box")[3]
            small_objects = bbox_area <= 0.05
            subset_def = dict(type="attribute", expr=small_objects)
            with results.use_subset(subset_def):
                results.print_report(classes=classes)

        Args:
            subset_def: the subset definition, which can be:

                -   a dict or list of dicts defining the subset. See above
                    for examples and see :func:`get_subset_view` for full
                    syntax
                -   a :class:`fiftyone.core.view.DatasetView` defining the
                    subset

        Returns:
            self
        
fiftyone/utils/eval/base.py