facet.explanation.parallel.ExplainerQueue#
- class facet.explanation.parallel.ExplainerQueue(explainer, X, y=None, *, interactions, max_job_size, **kwargs)[source]#
A queue splitting a data set to be explained into multiple jobs.
- Bases
JobQueue
[Union
[ndarray
[Any
,dtype
[Any
]],List
[ndarray
[Any
,dtype
[Any
]]]],Union
[ndarray
[Any
,dtype
[Any
]],List
[ndarray
[Any
,dtype
[Any
]]]]]- Metaclasses
- Parameters
explainer (
BaseExplainer
) – the SHAP explainer to useX (
Union
[ndarray
[Any
,dtype
[Any
]],DataFrame
,Pool
]) – the feature values of the observations to be explainedy (
Union
[ndarray
[Any
,dtype
[Any
]],Series
,None
]) – the target values of the observations to be explainedinteractions (
bool
) – ifFalse
, calculate SHAP values; ifTrue
, calculate SHAP interaction valuesmax_job_size (
int
) – the maximum number of observations to allocate to each jobkwargs (
Any
) – additional arguments specific to the explanation method
- Raises
NotImplementedError – if X is a
Pool
; this is currently not supported
Method summary
Called by
JobRunner.run_queue()
to aggregate the results of all jobs once they have all been run.Iterate the jobs in this queue.
Attribute summary
lock
The lock used by class
JobRunner
to prevent parallel executions of the same queuethe SHAP explainer to use
if
False
, calculate SHAP values; otherwise, calculate SHAP interaction valuesthe feature values of the observations to be explained
the target values of the observations to be explained
the maximum number of observations to allocate to each job
additional arguments specific to the explanation method
Definitions
- aggregate(job_results)[source]#
Called by
JobRunner.run_queue()
to aggregate the results of all jobs once they have all been run.- Parameters
job_results (
List
[Union
[ndarray
[Any
,dtype
[Any
]],List
[ndarray
[Any
,dtype
[Any
]]]]]) – list of job results, ordered corresponding to the sequence of jobs generated by methodjobs()
- Return type
Union
[ndarray
[Any
,dtype
[Any
]],List
[ndarray
[Any
,dtype
[Any
]]]]- Returns
the aggregated result of running the queue
- on_run()#
- X: numpy.ndarray[Any, numpy.dtype[Any]]#
the feature values of the observations to be explained
- explainer: facet.explanation.base.BaseExplainer#
the SHAP explainer to use
- y: Optional[numpy.ndarray[Any, numpy.dtype[Any]]]#
the target values of the observations to be explained