Skip to content

Commit 16eb29a

Browse files
committed
Fixed What-If plugin
Most of the fixes are done by James Wexler. Note that we are pinning Facets dependency to a specific commit for Polymer2 compatibility.
1 parent 946b433 commit 16eb29a

File tree

10 files changed

+49
-27
lines changed

10 files changed

+49
-27
lines changed

tensorboard/components/vz_bar_chart/vz-bar-chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</table>
4646
</div>
4747
<div id="chartdiv"></div>
48+
<style include="plottable-style"></style>
4849
<style>
4950
:host {
5051
-webkit-user-select: none;

tensorboard/components/vz_bar_chart/vz-bar-chart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class BarChart {
285285
tooltipHeaderRow.insert('th', ':first-child');
286286

287287
const plot = this.plot;
288-
const pointer = new Plottable.Interactions.Pointer();
288+
const pointer = new vz_chart_helpers.PointerInteraction();
289289
pointer.attachTo(plot);
290290

291291
var hideTooltips = () => {

tensorboard/components/vz_example_viewer/vz-example-viewer.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ Polymer({
238238
* display.
239239
*/
240240
getFeaturesList: function(features: any, compareFeatures: any) {
241+
if (features == null) {
242+
return [];
243+
}
241244
const featuresList: NameAndFeature[] = [];
242245
const featureSet: {[key: string]: boolean} = {};
243246
let it = features.keys();
@@ -250,6 +253,9 @@ Polymer({
250253
next = it.next();
251254
}
252255
}
256+
if (compareFeatures == null) {
257+
return featuresList;
258+
}
253259
it = compareFeatures.keys();
254260
if (it) {
255261
let next = it.next();
@@ -292,6 +298,9 @@ Polymer({
292298

293299
getFilteredFeaturesList: function(featureList: NameAndFeature[],
294300
searchValue: string, saliency: SaliencyMap) {
301+
if (featureList == null) {
302+
return;
303+
}
295304
let filtered = featureList;
296305
const checkSal = saliency && Object.keys(saliency).length > 0;
297306
// Create a dict of feature names to the total absolute saliency of all
@@ -1416,7 +1425,7 @@ Polymer({
14161425
},
14171426

14181427
featureMoreClicked: function(event: Event) {
1419-
const button = event.srcElement.parentElement;
1428+
const button = event.srcElement;
14201429
const feature = (button as any).dataFeature;
14211430
const dialog = this.$$('#' + this.sanitizeFeature(feature) + '_dialog');
14221431
dialog.positionTarget = button;

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tf_web_library(
1717
":tf_inference_viewer",
1818
"//tensorboard/components/vz_example_viewer",
1919
"//tensorboard/components/vz_bar_chart",
20-
"//tensorboard/components/vz_line_chart",
20+
"//tensorboard/components/vz_line_chart2",
2121
"@ai_google_pair_facets//facets_dive/components/facets_dive",
2222
"@ai_google_pair_facets//facets_overview/components/facets_overview",
2323
"@org_polymer_iron_collapse",

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/demo/tf-interactive-inference-age-demo.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
width: 100%;
3131
}
3232
</style>
33-
<tf-interactive-inference-dashboard id="dash" local="true" model-type="regression" model-name="demo" inference-address="demo">
33+
<tf-interactive-inference-dashboard id="dash" local="true" model-type="regression">
3434
</tf-interactive-inference-dashboard>
3535
</template>
3636
<script>
@@ -44,6 +44,8 @@
4444
categories: Object,
4545
},
4646
ready: async function() {
47+
this.$.dash.modelName = "demo";
48+
this.$.dash.inferenceAddress = "demo";
4749
this.$.dash.updateNumberOfModels();
4850
this.means = {
4951
'age': 38.64358543876172,

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/demo/tf-interactive-inference-image-demo.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
</style>
3737
<canvas id="spritecanvas"></canvas>
38-
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]" model-name="demo" inference-address="demo">
38+
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]">
3939
</tf-interactive-inference-dashboard>
4040
</template>
4141
<script>
@@ -52,6 +52,8 @@
5252
images: Array,
5353
},
5454
ready: async function() {
55+
this.$.dash.modelName = "demo";
56+
this.$.dash.inferenceAddress = "demo";
5557
this.$.dash.updateNumberOfModels();
5658
this.model = await tf.loadModel(tf.io.browserHTTPRequest(
5759
'data/images/model.json', {credentials: 'include'}));

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/demo/tf-interactive-inference-iris-demo.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
width: 100%;
3131
}
3232
</style>
33-
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]" model-name="demo" inference-address="demo">
33+
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]">
3434
</tf-interactive-inference-dashboard>
3535
</template>
3636
<script>
@@ -45,6 +45,8 @@
4545
'Iris-virginica']},
4646
},
4747
ready: async function() {
48+
this.$.dash.modelName = "demo";
49+
this.$.dash.inferenceAddress = "demo";
4850
this.$.dash.multiClass = true;
4951
this.$.dash.updateNumberOfModels();
5052
this.model = await tf.loadModel(tf.io.browserHTTPRequest(

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/demo/tf-interactive-inference-multi-demo.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
width: 100%;
3131
}
3232
</style>
33-
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]" model-name="1, 2" inference-address="demo1, demo2">
33+
<tf-interactive-inference-dashboard id="dash" local="true" label-vocab="[[labelVocab]]">
3434
</tf-interactive-inference-dashboard>
3535
</template>
3636
<script>
@@ -45,6 +45,8 @@
4545
labelVocab: {type: Array, value: ['<=50k', '>50k']},
4646
},
4747
ready: async function() {
48+
this.$.dash.modelName = "1, 2";
49+
this.$.dash.inferenceAddress = "demo1, demo2";
4850
this.$.dash.updateNumberOfModels();
4951
this.means = {
5052
'age': 38.64358543876172,

tensorboard/plugins/interactive_inference/tf_interactive_inference_dashboard/tf-interactive-inference-dashboard.html

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<link rel="import" href="../tf-tensorboard/plugin-dialog.html">
4646
<link rel="import" href="../tf-tensorboard/registry.html">
4747
<link rel="import" href="../vz-bar-chart/vz-bar-chart.html">
48-
<link rel="import" href="../vz-line-chart/vz-line-chart.html">
48+
<link rel="import" href="../vz-line-chart2/vz-line-chart2.html">
4949
<link rel="import" href="./tf-confusion-matrix.html">
5050
<link rel="import" href="./tf-inference-viewer.html">
5151
<link rel="import" href="../facets-dive/components/facets-dive/facets-dive.html">
@@ -76,6 +76,10 @@
7676
--wit-color-gray300: #DADCE0;
7777
}
7878

79+
[hidden] {
80+
display: none !important;
81+
}
82+
7983
#classification {
8084
width: 40%;
8185
}
@@ -404,7 +408,7 @@
404408
background: white;
405409
}
406410

407-
:host vz-line-chart {
411+
:host vz-line-chart2 {
408412
margin: 12px 12px 12px 24px;
409413
height: 180px;
410414
width: 300px;
@@ -1228,7 +1232,7 @@ <h2>Show similarity to selected datapoint</h2>
12281232
<paper-radio-button class="dist-radio" name="L2">L2</paper-radio-button>
12291233
</paper-radio-group>
12301234
<paper-dropdown-menu label="Apply to datapoints visualization" class="threshold-dropdown distance-vis-dropdown">
1231-
<paper-listbox class="dropdown-content" selected="{{facetDistSetting}}" attr-for-selected="name">
1235+
<paper-listbox slot="dropdown-content" selected="{{facetDistSetting}}" attr-for-selected="name">
12321236
<paper-item name="colorBy">Color By</paper-item>
12331237
<paper-item name="horizontalFacet">X-Axis Binning</paper-item>
12341238
<paper-item name="verticalFacet">Y-Axis Binning</paper-item>
@@ -1354,7 +1358,7 @@ <h2>Show similarity to selected datapoint</h2>
13541358
<paper-input value="{{featureSearchValue}}" label="Search features"
13551359
class="datapoint-control-filter-input feature-search-input"
13561360
disabled$="[[!hasSelected(selectedExampleAndInference)]]" no-label-float>
1357-
<iron-icon icon="icons:search" prefix></iron-icon>
1361+
<iron-icon icon="icons:search" slot="prefix"></iron-icon>
13581362
</paper-input>
13591363
</div>
13601364
<div class="datapoint-right-controls-holder">
@@ -1543,7 +1547,7 @@ <h2>Show similarity to selected datapoint</h2>
15431547
<template is="dom-if" if="[[shouldShowLabelDropdown_(stats)]]">
15441548
<div class="flex">
15451549
<paper-dropdown-menu label="Ground Truth Feature" class="threshold-dropdown">
1546-
<paper-listbox class="dropdown-content" selected="{{selectedLabelFeature}}" attr-for-selected="name">
1550+
<paper-listbox slot="dropdown-content" selected="{{selectedLabelFeature}}" attr-for-selected="name">
15471551
<template is="dom-repeat" items="[[getFeatureList_(stats)]]">
15481552
<paper-item name="[[item]]">[[getFeatureName_(item)]]</paper-item>
15491553
</template>
@@ -1593,7 +1597,7 @@ <h2>Show similarity to selected datapoint</h2>
15931597
<template is="dom-if" if="[[shouldShowFeatureDropdown_(stats)]]">
15941598
<div class="flex">
15951599
<paper-dropdown-menu label="Slice by" class="threshold-dropdown">
1596-
<paper-listbox class="dropdown-content" selected="{{selectedBreakdownFeature}}" attr-for-selected="name">
1600+
<paper-listbox slot="dropdown-content" selected="{{selectedBreakdownFeature}}" attr-for-selected="name">
15971601
<template is="dom-repeat" items="[[getFeatureList_(stats)]]">
15981602
<paper-item name="[[item]]">[[getFeatureName_(item)]]</paper-item>
15991603
</template>
@@ -1609,7 +1613,7 @@ <h2>Show similarity to selected datapoint</h2>
16091613
<div class="flex">
16101614
<template is="dom-if" if="[[shouldShowSecondFeatureDropdown_(selectedBreakdownFeature)]]">
16111615
<paper-dropdown-menu label="Slice by (secondary)" class="threshold-dropdown">
1612-
<paper-listbox class="dropdown-content" selected="{{selectedSecondBreakdownFeature}}" attr-for-selected="name">
1616+
<paper-listbox slot="dropdown-content" selected="{{selectedSecondBreakdownFeature}}" attr-for-selected="name">
16131617
<template is="dom-repeat" items="[[getFeatureList_(stats)]]">
16141618
<paper-item name="[[item]]">[[getFeatureName_(item)]]</paper-item>
16151619
</template>
@@ -1738,7 +1742,7 @@ <h2>Show similarity to selected datapoint</h2>
17381742
</paper-icon-button>
17391743
</div>
17401744
<paper-dropdown-menu label="Sort by" class="threshold-dropdown perf-table-sort-menu">
1741-
<paper-listbox class="dropdown-content" selected="{{selectedFeatureSort}}" attr-for-selected="name">
1745+
<paper-listbox slot="dropdown-content" selected="{{selectedFeatureSort}}" attr-for-selected="name">
17421746
<template is="dom-repeat" items="[[getFeatureSortBy(modelType, multiClass)]]">
17431747
<paper-item name="[[item]]">[[item]]</paper-item>
17441748
</template>
@@ -1788,7 +1792,7 @@ <h2>Show similarity to selected datapoint</h2>
17881792
<div class="perf-table-threshold">
17891793
<template is="dom-repeat" items="{{featureValueThreshold.threshold}}">
17901794
<paper-slider class$="[[getSliderClass(index)]]" editable=true min="0" max="1" step="0.01" immediate-value="{{item.threshold}}"
1791-
value="[[item.threshold]]" on-value-changed="refreshInferencesNoRegen_" on-down="resetOptimizationSelected_">
1795+
value="[[item.threshold]]" on-value-changed="refreshInferencesNoRegen_" on-immediate-value-changed="refreshInferencesNoRegen_" on-down="resetOptimizationSelected_">
17921796
</paper-slider>
17931797
</template>
17941798
</div>
@@ -1835,10 +1839,10 @@ <h2>Show similarity to selected datapoint</h2>
18351839
</div>
18361840
<div class="roc-x-label">False positive rate</div>
18371841
<div class="roc-y-label">True positive rate</div>
1838-
<vz-line-chart id="[[getPrChartId(index)]]" class="pr-line-chart"
1842+
<vz-line-chart2 id="[[getPrChartId(index)]]" class="pr-line-chart"
18391843
x-axis-formatter="[[getSimpleAxisFormatter(axisPrecision)]]"
18401844
y-axis-formatter="[[getSimpleAxisFormatter(axisPrecision)]]">
1841-
</vz-line-chart>
1845+
</vz-line-chart2>
18421846
</div>
18431847
</template>
18441848
</div>
@@ -1860,7 +1864,7 @@ <h2>Show similarity to selected datapoint</h2>
18601864
<div class="perf-table-threshold">
18611865
<template is="dom-repeat" items="{{overallThresholds}}">
18621866
<paper-slider class$="[[getSliderClass(index)]]" editable=true min="0" max="1" step="0.01" immediate-value="{{item.threshold}}"
1863-
value="[[item.threshold]]" on-value-changed="refreshInferencesNoRegen_" on-down="resetOptimizationSelected_">
1867+
value="[[item.threshold]]" on-value-changed="refreshInferencesNoRegen_" on-immediate-value-changed="refreshInferencesNoRegen_" on-down="resetOptimizationSelected_">
18641868
</paper-slider>
18651869
</template>
18661870
</div>
@@ -1906,10 +1910,10 @@ <h2>Show similarity to selected datapoint</h2>
19061910
</div>
19071911
<div class="roc-x-label">False positive rate</div>
19081912
<div class="roc-y-label">True positive rate</div>
1909-
<vz-line-chart id="prchart" class="pr-line-chart"
1913+
<vz-line-chart2 id="prchart" class="pr-line-chart"
19101914
x-axis-formatter="[[getSimpleAxisFormatter(axisPrecision)]]"
19111915
y-axis-formatter="[[getSimpleAxisFormatter(axisPrecision)]]">
1912-
</vz-line-chart>
1916+
</vz-line-chart2>
19131917
</div>
19141918
</template>
19151919
</div>
@@ -3474,6 +3478,7 @@ <h2>Show similarity to selected datapoint</h2>
34743478
else if (selection == 'equalopp') {
34753479
this.equalOppoClicked_();
34763480
}
3481+
this.updateInferenceStats_(true);
34773482
},
34783483

34793484
costRatioChanged_: function() {
@@ -4965,7 +4970,7 @@ <h2>Show similarity to selected datapoint</h2>
49654970

49664971
const holder = document.createElement('div');
49674972
holder.classList.add('pd-holder');
4968-
const chart = document.createElement('vz-line-chart');
4973+
const chart = document.createElement('vz-line-chart2');
49694974
const colorScale = [];
49704975
const thresholdSeries = [];
49714976
const valueFormatter = vz_chart_helpers.multiscaleFormatter(

third_party/js.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,10 @@ def tensorboard_js_workspace():
317317

318318
http_archive(
319319
name = "ai_google_pair_facets",
320-
sha256 = "e3f7b7b3c194c1772d16bdc8b348716c0da59a51daa03ef4503cf06c073caafc",
321-
strip_prefix = "facets-0.2.1",
320+
sha256 = "03010e520ba7f01c596e092805dc9331b13831cccb1926b9659cc2d01d1e1a22",
321+
strip_prefix = "facets-p2",
322322
urls = [
323-
"http://mirror.bazel.build/github.com/pair-code/facets/archive/0.2.1.tar.gz",
324-
"https://github.com/pair-code/facets/archive/0.2.1.tar.gz",
323+
"https://github.com/pair-code/facets/archive/p2.tar.gz",
325324
],
326325
)
327326
web_library_external(
@@ -340,7 +339,7 @@ def tensorboard_js_workspace():
340339
strip_prefix = "vaadin-split-layout-1.1.0",
341340
path = "/vaadin-split-layout",
342341
)
343-
342+
344343
web_library_external(
345344
name = "vaadin_vaadin_grid",
346345
licenses = ["notice"], # Apache License 2.0

0 commit comments

Comments
 (0)