{ "cells": [ { "cell_type": "markdown", "id": "2afe0cdb", "metadata": {}, "source": [ "# Time Limit" ] }, { "cell_type": "markdown", "id": "8694bde4", "metadata": {}, "source": [ "The explanations computed by the explainer can be hard to get, for computational reasons. As a consequence, the ```time_limit``` parameter must be considered in some methods for computing explanations. If this ```time_limit``` is reached, then the method stops and can return an approximation of the desired reason or ```[]``` if no approximation was found. By default, the time_limit parameter is set to ```None```, it gives an infinite amount of time for the calculation of an explanation." ] }, { "cell_type": "markdown", "id": "75796e60", "metadata": {}, "source": [ "Moreover, all explainers have a variable ```elapsed_time``` set to the time in seconds needed by the last call of\n", "the method used for computing an explanation. It is equal to ```Explainer.TIMEOUT``` if ```time_limit``` was reached." ] }, { "cell_type": "markdown", "id": "843063e1", "metadata": {}, "source": [ "The following piece of code provides an example of usage." ] }, { "cell_type": "code", "execution_count": null, "id": "117f2298", "metadata": {}, "outputs": [], "source": [ "minimal_constrastive = explaine.minimal_contrastive_reason(time_limit=10)\n", "if explainer.elapsed_time == Explainer.TIMEOUT:\n", " print(\"time out\")\n", " print(f\"minimal contrastive: {minimal_constrastive} is an approximation.\")\n", "else: \n", " print(\"time to compute the minimal\", explainer.elapsed_time)\n", " print(\"minimal contrastive:\", minimal_constrastive\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }