Skip to content

Commit

Permalink
vega: templates: make confusion matrix interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
pared committed May 11, 2022
1 parent 28c1495 commit 46dc455
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/dvc_render/vega_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,34 @@ class ConfusionTemplate(Template):
}
},
},
{
"selection": {
"label": {
"type": "single",
"on": "mouseover",
"encodings": ["x", "y"],
"empty": "none",
"clear": "mouseout",
}
},
"mark": "rect",
"encoding": {
"tooltip": [
{"field": "actual", "type": "nominal"},
{"field": "predicted", "type": "nominal"},
],
"opacity": {
"condition": {"selection": "label", "value": 1},
"value": 0,
},
},
},
{
"transform": [{"filter": {"selection": "label"}}],
"layer": [
{"mark": {"type": "rect", "color": "lightpink"}},
],
},
{
"mark": "text",
"encoding": {
Expand Down Expand Up @@ -257,6 +285,34 @@ class NormalizedConfusionTemplate(Template):
}
},
},
{
"selection": {
"label": {
"type": "single",
"on": "mouseover",
"encodings": ["x", "y"],
"empty": "none",
"clear": "mouseout",
}
},
"mark": "rect",
"encoding": {
"tooltip": [
{"field": "actual", "type": "nominal"},
{"field": "predicted", "type": "nominal"},
],
"opacity": {
"condition": {"selection": "label", "value": 1},
"value": 0,
},
},
},
{
"transform": [{"filter": {"selection": "label"}}],
"layer": [
{"mark": {"type": "rect", "color": "lightpink"}},
],
},
{
"mark": "text",
"encoding": {
Expand Down

0 comments on commit 46dc455

Please sign in to comment.