.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/vision/distribution/plot_new_labels.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_checks_gallery_vision_distribution_plot_new_labels.py: New Labels ========== This notebooks provides an overview for using and understanding the New Labels check. **Structure:** * `How the check works <#How-the-check-works>`__ * `Run the check <#run-the-check>`__ * `Define a condition <#define-a-condition>`__ How the check works ----------------- In this check we count the frequency of each class id in the test set then check which of them do not apper in the training set. Note that by default this check run on a sample of the data set and so it is possible that class ids that are rare in the train set will also be considered as new labels in the test set. .. GENERATED FROM PYTHON SOURCE LINES 23-25 Run the Check ----------------- .. GENERATED FROM PYTHON SOURCE LINES 25-34 .. code-block:: default from deepchecks.vision.datasets.detection import coco from deepchecks.vision.checks import NewLabels coco_train = coco.load_dataset(train=True, object_type='VisionData', shuffle=False) coco_test = coco.load_dataset(train=False, object_type='VisionData', shuffle=False) result = NewLabels().run(coco_train, coco_test) result .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Validating Input: 0%| | 0/1 [00:00

New Labels

Detects labels that apper only in the test set.

Additional Outputs

Label "donut"

Appears 14 times in test set.

Label "tennis racket"

Appears 7 times in test set.

Label "boat"

Appears 6 times in test set.


.. GENERATED FROM PYTHON SOURCE LINES 35-39 Observe the check’s output ~~~~~~~~~~~~~~~~~~ The check searches for new labels in the test set. The value output is a dictionary containing of appearances of each newly found class_id in addition to the total number of labels in the test set for comparison purposes. .. GENERATED FROM PYTHON SOURCE LINES 39-42 .. code-block:: default result.value .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'donut': 14, 'tennis racket': 7, 'boat': 6, 'cat': 4, 'laptop': 3, 'mouse': 2, 'tv': 2, 'toilet': 2, 'skis': 1, 'bear': 1, 'all_labels': 387} .. GENERATED FROM PYTHON SOURCE LINES 43-50 Define a condition ------------------- The check has a default condition which can be defined. The condition verifies that the ratio of new labels out of the total number of labels in the test set is smaller than a given threshold. If the check is run with the default sampling mechanism we recommend on setting the condition threshold to a small percentage instead of setting it to 0. .. GENERATED FROM PYTHON SOURCE LINES 50-54 .. code-block:: default check = NewLabels().add_condition_new_label_ratio_not_greater_than(0.05) check.run(coco_train, coco_test) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Validating Input: 0%| | 0/1 [00:00

New Labels

Detects labels that apper only in the test set.

Conditions Summary
Status Condition More Info
✖
Percentage of new labels in the test set not above 5%. 10.85% of labels found in test set were not in train set. New labels most common in test set: ['donut', 'tennis racket', 'boat']
Additional Outputs

Label "donut"

Appears 14 times in test set.

Label "tennis racket"

Appears 7 times in test set.

Label "boat"

Appears 6 times in test set.


.. GENERATED FROM PYTHON SOURCE LINES 55-56 In this case the condition identified that a major portion of the test set labels do not appear in the training set. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.431 seconds) .. _sphx_glr_download_checks_gallery_vision_distribution_plot_new_labels.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_new_labels.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_new_labels.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_