.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/tabular/model_evaluation/plot_model_inference_time.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_tabular_model_evaluation_plot_model_inference_time.py: .. _plot_tabular_model_inference_time: Model Inference Time ********************* This notebook provides an overview for using and understanding the Model Inference Time check. **Structure:** * `What is the Model Inference Time check? <#what-is-the-model-inference-time-check>`__ * `Generate data & model <#generate-data-model>`__ * `Run the check <#run-the-check>`__ * `Define a condition <#define-a-condition>`__ What is the Model Inference Time check? ======================================== The ``ModelInferenceTime`` check measures the model's average inference time (in seconds) per sample. Inference time is an important metric for prediction models, especially in real-time applications and data streaming processes, where a fast runtime can affect the user's experience or the overall system load. .. GENERATED FROM PYTHON SOURCE LINES 27-29 Imports ============= .. GENERATED FROM PYTHON SOURCE LINES 29-36 .. code-block:: default from sklearn.datasets import load_iris from sklearn.ensemble import AdaBoostClassifier from sklearn.model_selection import train_test_split from deepchecks.tabular import Dataset from deepchecks.tabular.checks import ModelInferenceTime .. GENERATED FROM PYTHON SOURCE LINES 37-39 Generate data & model ======================= .. GENERATED FROM PYTHON SOURCE LINES 39-47 .. code-block:: default iris = load_iris(as_frame=True) train, test = train_test_split(iris.frame, test_size=0.33, random_state=42) train_ds = Dataset(train, features=iris.feature_names, label='target') test_ds = Dataset(test, features=iris.feature_names, label='target') clf = AdaBoostClassifier().fit(train_ds.data[train_ds.features], train_ds.data[train_ds.label_name]) .. GENERATED FROM PYTHON SOURCE LINES 48-50 Run the check ============= .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: default check = ModelInferenceTime() check.run(test_ds, clf) .. raw:: html
Model Inference Time


.. GENERATED FROM PYTHON SOURCE LINES 54-58 Define a condition =================== A condition for the average inference time per sample can be defined. Here, we define the threshold to be 0.00001 seconds. .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: default check = ModelInferenceTime().add_condition_inference_time_less_than(value=0.00001) check.run(test_ds, clf) .. raw:: html
Model Inference Time


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.159 seconds) .. _sphx_glr_download_checks_gallery_tabular_model_evaluation_plot_model_inference_time.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_model_inference_time.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_model_inference_time.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_