.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/vision/model_evaluation/plot_single_dataset_performance.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_model_evaluation_plot_single_dataset_performance.py: .. _plot_vision_single_dataset_performance: Single Dataset Performance ********************************* This notebooks provides an overview for using and understanding single dataset performance check. **Structure:** * `What Is the Purpose of the Check? <#what-is-the-purpose-of-the-check>`__ * `Generate data an model <#generate-data-and-model>`__ * `Run the check <#run-the-check>`__ * `Define a condition <#define-a-condition>`__ What Is the Purpose of the Check? ================================= This check returns the results from a dict of metrics, in the format metric name: scorer, calculated for the given model dataset. The scorer can be an ignite.Metric or Sklearn scorer. Use this check to evaluate the performance on a single vision dataset such as a test set. .. GENERATED FROM PYTHON SOURCE LINES 25-27 Generate data and model ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: default from deepchecks.vision.checks import SingleDatasetPerformance from deepchecks.vision.datasets.classification import mnist .. GENERATED FROM PYTHON SOURCE LINES 32-37 .. code-block:: default mnist_model = mnist.load_model() train_ds = mnist.load_dataset(train=True, object_type='VisionData') .. GENERATED FROM PYTHON SOURCE LINES 38-45 Run the check ------------- We will run the check with the model defined above. The check will use the default classification metrics - `Precision `__. and `Recall `__. .. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: default check = SingleDatasetPerformance() result = check.run(train_ds, mnist_model) result .. rst-class:: sphx-glr-script-out .. code-block:: none Validating Input: | | 0/1 [Time: 00:00] Validating Input: |#####| 1/1 [Time: 00:00] Ingesting Batches: | | 0/157 [Time: 00:00] Ingesting Batches: |############### | 15/157 [Time: 00:00] Ingesting Batches: |############################## | 30/157 [Time: 00:00] Ingesting Batches: |############################################## | 46/157 [Time: 00:00] Ingesting Batches: |############################################################# | 61/157 [Time: 00:00] Ingesting Batches: |############################################################################ | 76/157 [Time: 00:00] Ingesting Batches: |########################################################################################### | 91/157 [Time: 00:00] Ingesting Batches: |########################################################################################################## | 106/157 [Time: 00:00] Ingesting Batches: |########################################################################################################################## | 122/157 [Time: 00:00] Ingesting Batches: |########################################################################################################################################## | 138/157 [Time: 00:00] Ingesting Batches: |########################################################################################################################################################## | 154/157 [Time: 00:01] Ingesting Batches: |#############################################################################################################################################################| 157/157 [Time: 00:01] Computing Check: | | 0/1 [Time: 00:00] Computing Check: |#####| 1/1 [Time: 00:00] .. raw:: html
Single Dataset Performance


.. GENERATED FROM PYTHON SOURCE LINES 52-55 If you have a GPU, you can speed up this check by passing it as an argument to .run() as device= To display the results in an IDE like PyCharm, you can use the following code: .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: default # result.show_in_window() .. GENERATED FROM PYTHON SOURCE LINES 58-59 The result will be displayed in a new window. .. GENERATED FROM PYTHON SOURCE LINES 61-62 Now we will run a check with a metric different from the defaults- F-1. .. GENERATED FROM PYTHON SOURCE LINES 62-68 .. code-block:: default from ignite.metrics import Fbeta check = SingleDatasetPerformance(scorers={'f1': Fbeta(1)}) result = check.run(train_ds, mnist_model) result .. rst-class:: sphx-glr-script-out .. code-block:: none Validating Input: | | 0/1 [Time: 00:00] Validating Input: |#####| 1/1 [Time: 00:00] Ingesting Batches: | | 0/157 [Time: 00:00] Ingesting Batches: |############### | 15/157 [Time: 00:00] Ingesting Batches: |############################## | 30/157 [Time: 00:00] Ingesting Batches: |############################################# | 45/157 [Time: 00:00] Ingesting Batches: |############################################################ | 60/157 [Time: 00:00] Ingesting Batches: |########################################################################### | 75/157 [Time: 00:00] Ingesting Batches: |########################################################################################## | 90/157 [Time: 00:00] Ingesting Batches: |######################################################################################################### | 105/157 [Time: 00:00] Ingesting Batches: |######################################################################################################################## | 120/157 [Time: 00:00] Ingesting Batches: |####################################################################################################################################### | 135/157 [Time: 00:00] Ingesting Batches: |###################################################################################################################################################### | 150/157 [Time: 00:01] Ingesting Batches: |#############################################################################################################################################################| 157/157 [Time: 00:01] Computing Check: | | 0/1 [Time: 00:00] Computing Check: |#####| 1/1 [Time: 00:00] .. raw:: html
Single Dataset Performance


.. GENERATED FROM PYTHON SOURCE LINES 69-74 Define a Condition ================== We can define a condition to validate that our model performance score is above or below a certain threshold. The condition is defined as a function that takes the results of the check as input and returns a ConditionResult object. .. GENERATED FROM PYTHON SOURCE LINES 74-80 .. code-block:: default check = SingleDatasetPerformance() check.add_condition_greater_than(0.5) result = check.run(train_ds, mnist_model) result.show(show_additional_outputs=False) .. rst-class:: sphx-glr-script-out .. code-block:: none Validating Input: | | 0/1 [Time: 00:00] Validating Input: |#####| 1/1 [Time: 00:00] Ingesting Batches: | | 0/157 [Time: 00:00] Ingesting Batches: |############### | 15/157 [Time: 00:00] Ingesting Batches: |############################### | 31/157 [Time: 00:00] Ingesting Batches: |############################################## | 46/157 [Time: 00:00] Ingesting Batches: |############################################################## | 62/157 [Time: 00:00] Ingesting Batches: |############################################################################## | 78/157 [Time: 00:00] Ingesting Batches: |############################################################################################## | 94/157 [Time: 00:00] Ingesting Batches: |############################################################################################################# | 109/157 [Time: 00:00] Ingesting Batches: |############################################################################################################################ | 124/157 [Time: 00:00] Ingesting Batches: |############################################################################################################################################ | 140/157 [Time: 00:00] Ingesting Batches: |############################################################################################################################################################ | 156/157 [Time: 00:01] Ingesting Batches: |#############################################################################################################################################################| 157/157 [Time: 00:01] Computing Check: | | 0/1 [Time: 00:00] Computing Check: |#####| 1/1 [Time: 00:00] .. raw:: html
Single Dataset Performance


.. GENERATED FROM PYTHON SOURCE LINES 81-83 We can also define a condition on a specific metric (or a subset of the metrics) that was passed to the check and a specific class, instead of testing all the metrics and all the classes which is the default mode. .. GENERATED FROM PYTHON SOURCE LINES 83-88 .. code-block:: default check = SingleDatasetPerformance() check.add_condition_greater_than(0.8, metrics=['Precision'], class_mode='3') result = check.run(train_ds, mnist_model) result.show(show_additional_outputs=False) .. rst-class:: sphx-glr-script-out .. code-block:: none Validating Input: | | 0/1 [Time: 00:00] Validating Input: |#####| 1/1 [Time: 00:00] Ingesting Batches: | | 0/157 [Time: 00:00] Ingesting Batches: |################ | 16/157 [Time: 00:00] Ingesting Batches: |################################ | 32/157 [Time: 00:00] Ingesting Batches: |################################################ | 48/157 [Time: 00:00] Ingesting Batches: |################################################################ | 64/157 [Time: 00:00] Ingesting Batches: |################################################################################ | 80/157 [Time: 00:00] Ingesting Batches: |################################################################################################ | 96/157 [Time: 00:00] Ingesting Batches: |###############################################################################################################9 | 112/157 [Time: 00:00] Ingesting Batches: |################################################################################################################################ | 128/157 [Time: 00:00] Ingesting Batches: |################################################################################################################################################ | 144/157 [Time: 00:00] Ingesting Batches: |#############################################################################################################################################################| 157/157 [Time: 00:01] Computing Check: | | 0/1 [Time: 00:00] Computing Check: |#####| 1/1 [Time: 00:00] .. raw:: html
Single Dataset Performance


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.490 seconds) .. _sphx_glr_download_checks_gallery_vision_model_evaluation_plot_single_dataset_performance.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_single_dataset_performance.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_single_dataset_performance.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_