Confusion matrix
@@ -5032,10 +5036,41 @@
Show similarity to selected datapoint
*/
addChart: function(chartType, featureName, data){
let chart;
+ let dataToChart = data;
+
+ // If multiclass and there are more inferred classes than the set
+ // number of classes to display, then filter the classes to display
+ // in the chart down to the top scoring classes.
+ if (this.isMultiClass_(this.modelType, this.multiClass)) {
+ dataToChart = [];
+ for (let modelIdx = 0; modelIdx < data.length; modelIdx++) {
+ let modelDataToChart = {};
+ if (Object.keys(data[modelIdx]).length >
+ Number(this.maxInferenceEntriesPerRun)) {
+ const exampleId = this.selected &&
+ this.selected.length > 0 ? this.selected[0] : 0;
+ // Get the class labels of the top scoring classes from the most
+ // recent inference.
+ const currentExample = this.examplesAndInferences[exampleId];
+ const lastInference = currentExample.inferences[
+ currentExample.inferences.length - 1];
+ const labels = lastInference[modelIdx].slice(
+ 0, this.maxInferenceEntriesPerRun);
+ for (let labelIdx = 0; labelIdx < labels.length; labelIdx++) {
+ const label = labels[labelIdx].label;
+ modelDataToChart[label] = data[modelIdx][label];
+ }
+ } else {
+ modelDataToChart = data[modelIdx];
+ }
+ dataToChart.push(modelDataToChart);
+ }
+ }
+
if (chartType == 'numeric'){
- chart = this.makeLineChart(featureName, data);
+ chart = this.makeLineChart(featureName, dataToChart);
} else if (chartType == 'categorical'){
- chart = this.makeBarChart(featureName, data);
+ chart = this.makeBarChart(featureName, dataToChart);
} else {
console.error('Unknown chartType: ' + chartType);
}