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

Alibi explain 110 fix #3501

Merged
merged 2 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/alibi-explain-server/alibiexplainer/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
def create_application(self):
return tornado.web.Application(
[
(r"/v1/models/([a-zA-Z0-9_-]+):explain",
(r"/v1/models/([a-zA-Z0-9_-]*):explain",
ExplainV2Handler, dict(model=self.registered_model)),
(r"/api/v0.1/explain",
ExplainHandler, dict(model=self.registered_model)),
Expand Down Expand Up @@ -112,4 +112,3 @@ def post(self, model_name):
)
response =self.model.explain(body, model_name=model_name)
self.write(response)

1 change: 1 addition & 0 deletions doc/source/analytics/explainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ The explain method is also supported for tensorflow and v2 kfserving protocols.
| kfserving | `http://<host>/<ingress-path>/v2/models/<model-name>/explain` |


Note: for `tensorflow` protocol we support similar non-standard extension as for the [prediction API](../graph/protocols.md#rest-and-grpc-tensorflow-protocol), `http://<host>/<ingress-path>/v1/models/:explain`.
23 changes: 22 additions & 1 deletion notebooks/explainer_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,27 @@
"plt.imshow(arr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# or using non-standard seldon extension\n",
"\n",
"test_example = X_test[idx : idx + 1].tolist()\n",
"payload = '{\"instances\":' + f\"{test_example}\" + \" }\"\n",
"cmd = f\"\"\"curl -s -d '{payload}' \\\n",
" http://localhost:8003/seldon/seldon/cifar10-classifier-explainer/default/v1/models/:explain \\\n",
" -H \"Content-Type: application/json\"\n",
"\"\"\"\n",
"ret = Popen(cmd, shell=True, stdout=PIPE)\n",
"raw = ret.stdout.read().decode(\"utf-8\")\n",
"explanation = json.loads(raw)\n",
"arr = np.array(explanation[\"data\"][\"anchor\"])\n",
"plt.imshow(arr)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1758,7 +1779,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand Down