Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeldonDeployment explainer description #2144

Closed
cr4zy-C opened this issue Jul 16, 2020 · 6 comments · Fixed by #2241
Closed

SeldonDeployment explainer description #2144

cr4zy-C opened this issue Jul 16, 2020 · 6 comments · Fixed by #2241
Assignees
Projects
Milestone

Comments

@cr4zy-C
Copy link

cr4zy-C commented Jul 16, 2020

Hi,
I am new to seldon, read through the documentation (may have overlooked it) and I have not found a description for the explainer part of the SeldonDeployment file. So i got some questions regarding it, but first if there is a documentation could someone point me to it?

For example in this file:

apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: income
spec:
  name: income
  annotations:
    seldon.io/rest-timeout: "100000"
  predictors:
  - graph:
      children: []
      implementation: SKLEARN_SERVER
      modelUri: gs://seldon-models/sklearn/income/model
      name: classifier
    explainer:
      type: AnchorTabular
      modelUri: gs://seldon-models/sklearn/income/explainer
    name: default
    replicas: 1

Regarding the explainer:

  1. Is the type just alibi specific or can also a custom type/explainer_model be used?
  2. To what points the modelUri? I read that AnchorTabular is a local explanation is, therefor no separate explanation_model can be trained. Does that mean the modelUri points to a (for example) python file with the interpretability logic?
  3. Is there always a modelUri needed? I saw an example where none was specified, why?
@ukclivecox
Copy link
Contributor

There is an example: https://docs.seldon.io/projects/seldon-core/en/latest/analytics/explainers.html
I agree we need more docs in this area.

To answer your questions

  • Explainer type is presently required. But actually we should extend it so you can define your own custom container.
  • modelUri is the URI of the "saved" explainer. Some Alibi techniques such as AnchorTabular needs to create some statistics of the training data so you should "fit" them and pickle the explainer.
  • A modelUri is not needed for some explainers, e.g. AnchorText.

Best to look at the Alibi project for details

@ukclivecox ukclivecox added this to To do in 1.3 via automation Jul 16, 2020
@ukclivecox ukclivecox added this to the 1.3 milestone Jul 16, 2020
@ukclivecox ukclivecox self-assigned this Jul 16, 2020
@cr4zy-C
Copy link
Author

cr4zy-C commented Jul 17, 2020

Thanks for the answer! Now some things are more clear, but other questions come up for me.

Do i understand it correctly: you just need a modelURI when you should "fit" the explainer and pickle it afterwards?
The pickled explainer is just an object and not a separate explanation model (because it needs access to the predict function of the model)?

@ukclivecox
Copy link
Contributor

Thanks for the answer! Now some things are more clear, but other questions come up for me.

Do i understand it correctly: you just need a modelURI when you should "fit" the explainer and pickle it afterwards?

Yes that is correct.

The pickled explainer is just an object and not a separate explanation model (because it needs access to the predict function of the model)?

Yes also correct. The AlibiExplainerWrapper image we run will load the Explainer object and manage updating the predict_fn

@Nithinbs18
Copy link

Hi @cliveseldon ,

I have been trying to use the explanation for a deployment, If I have understood it correctly we need not specify a modelUri for some explainers and I assume AnchorTabular is also one of them.

I have the below k8 manifest using MLFLOW_SERVER as implementation.

apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
  name: test-explain
spec:
  name: test-explain
  predictors:
    - graph:
        children: []
        implementation: MLFLOW_SERVER
        modelUri: s3://seldon/b
        envSecretRefName: seldon-init-container-secret
        name: classifier
      name: model-test-explain
      explainer:
        containerSpec:
          name: "explainer"
        type: AnchorTabular
      replicas: 1
      componentSpecs:
        - spec:
            containers:
              - name: classifier

But when I run this the explainer deployment ends up with the below error

Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/app-root/src/alibiexplainer/alibiexplainer/__main__.py", line 143, in <module>
    args.tf_data_type)
  File "/opt/app-root/src/alibiexplainer/alibiexplainer/explainer.py", line 73, in __init__
    self.wrapper:ExplainerWrapper = AnchorTabular(self._predict_fn, explainer, **config)
  File "/opt/app-root/src/alibiexplainer/alibiexplainer/anchor_tabular.py", line 35, in __init__
    self.prepare(**kwargs)
  File "/opt/app-root/src/alibiexplainer/alibiexplainer/anchor_tabular.py", line 54, in prepare
    raise Exception("Anchor_tabular requires training data")
Exception: Anchor_tabular requires training data

I have been trying to understand this and I am stuck and have no idea how to pass the training data.
Could you please suggest how to proceed?
Thanks in advance.

@ukclivecox
Copy link
Contributor

At present you will need to provide the Anchor Tabular explainer pickled with dill as explainer.dill.
We plan to refactor this in future to allow more flexibility.

@ukclivecox
Copy link
Contributor

Will be fixed by #2160

@ukclivecox ukclivecox moved this from To do to In Review in 1.3 Aug 23, 2020
1.3 automation moved this from In Review to Done Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
1.3
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants