|
1017 | 1017 | margin-left: 30px; |
1018 | 1018 | } |
1019 | 1019 |
|
| 1020 | + .scroll-x { |
| 1021 | + overflow-x: auto; |
| 1022 | + } |
| 1023 | + |
1020 | 1024 | .perf-table-clickable { |
1021 | 1025 | cursor: pointer; |
1022 | 1026 | } |
@@ -2081,7 +2085,7 @@ <h2>Show similarity to selected datapoint</h2> |
2081 | 2085 | </div> |
2082 | 2086 | </div> |
2083 | 2087 | <iron-collapse opened="{{featureValueThreshold.opened}}"> |
2084 | | - <div class="perf-table-entry-expanded flex-row-reverse"> |
| 2088 | + <div class="perf-table-entry-expanded flex-row-reverse scroll-x"> |
2085 | 2089 | <div> |
2086 | 2090 | <template is="dom-if" if="[[shouldShowFeaturePrCharts_(selectedLabelFeature, selectedBreakdownFeature, inferences)]]"> |
2087 | 2091 | <div class="conf-matrix-holder"> |
@@ -2124,7 +2128,7 @@ <h2>Show similarity to selected datapoint</h2> |
2124 | 2128 | </div> |
2125 | 2129 | </div> |
2126 | 2130 | </div> |
2127 | | - <div class="perf-table-entry-expanded flex-row-reverse"> |
| 2131 | + <div class="perf-table-entry-expanded flex-row-reverse scroll-x"> |
2128 | 2132 | <template is="dom-if" if="[[shouldShowOverallPrChart_(selectedLabelFeature, selectedBreakdownFeature, inferences)]]"> |
2129 | 2133 | <div class="conf-matrix-holder"> |
2130 | 2134 | <div class="conf-text">Confusion matrix</div> |
@@ -5032,10 +5036,41 @@ <h2>Show similarity to selected datapoint</h2> |
5032 | 5036 | */ |
5033 | 5037 | addChart: function(chartType, featureName, data){ |
5034 | 5038 | let chart; |
| 5039 | + let dataToChart = data; |
| 5040 | + |
| 5041 | + // If multiclass and there are more inferred classes than the set |
| 5042 | + // number of classes to display, then filter the classes to display |
| 5043 | + // in the chart down to the top scoring classes. |
| 5044 | + if (this.isMultiClass_(this.modelType, this.multiClass)) { |
| 5045 | + dataToChart = []; |
| 5046 | + for (let modelIdx = 0; modelIdx < data.length; modelIdx++) { |
| 5047 | + let modelDataToChart = {}; |
| 5048 | + if (Object.keys(data[modelIdx]).length > |
| 5049 | + Number(this.maxInferenceEntriesPerRun)) { |
| 5050 | + const exampleId = this.selected && |
| 5051 | + this.selected.length > 0 ? this.selected[0] : 0; |
| 5052 | + // Get the class labels of the top scoring classes from the most |
| 5053 | + // recent inference. |
| 5054 | + const currentExample = this.examplesAndInferences[exampleId]; |
| 5055 | + const lastInference = currentExample.inferences[ |
| 5056 | + currentExample.inferences.length - 1]; |
| 5057 | + const labels = lastInference[modelIdx].slice( |
| 5058 | + 0, this.maxInferenceEntriesPerRun); |
| 5059 | + for (let labelIdx = 0; labelIdx < labels.length; labelIdx++) { |
| 5060 | + const label = labels[labelIdx].label; |
| 5061 | + modelDataToChart[label] = data[modelIdx][label]; |
| 5062 | + } |
| 5063 | + } else { |
| 5064 | + modelDataToChart = data[modelIdx]; |
| 5065 | + } |
| 5066 | + dataToChart.push(modelDataToChart); |
| 5067 | + } |
| 5068 | + } |
| 5069 | + |
5035 | 5070 | if (chartType == 'numeric'){ |
5036 | | - chart = this.makeLineChart(featureName, data); |
| 5071 | + chart = this.makeLineChart(featureName, dataToChart); |
5037 | 5072 | } else if (chartType == 'categorical'){ |
5038 | | - chart = this.makeBarChart(featureName, data); |
| 5073 | + chart = this.makeBarChart(featureName, dataToChart); |
5039 | 5074 | } else { |
5040 | 5075 | console.error('Unknown chartType: ' + chartType); |
5041 | 5076 | } |
|
0 commit comments