Link Search Menu Expand Document
Papers Video GitHub EXPEKCTATION About
download notebook

Time Limit

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.

Moreover, all explainers have a variable elapsed_time set to the time in seconds needed by the last call of the method used for computing an explanation. It is equal to Explainer.TIMEOUT if time_limit was reached.

The following piece of code provides an example of usage.

minimal_constrastive = explaine.minimal_contrastive_reason(time_limit=10)
if explainer.elapsed_time == Explainer.TIMEOUT:
    print("time out")
    print(f"minimal contrastive: {minimal_constrastive} is an approximation.")
    print("time to compute the minimal", explainer.elapsed_time)
    print("minimal contrastive:", minimal_constrastive")