kpfadnis commited on
Commit
19ed471
·
1 Parent(s): 2d6d7db

feat (Performance Overview): Allow user to hide metrics from tables.

Browse files
src/components/filters/Filters.tsx CHANGED
@@ -26,6 +26,7 @@ import { FilterableMultiSelect, Tag, Tooltip, Button } from '@carbon/react';
26
  import { ChevronUp, ChevronDown, Filter } from '@carbon/icons-react';
27
 
28
  import classes from './Filters.module.scss';
 
29
  // ===================================================================================
30
  // TYPES
31
  // ===================================================================================
 
26
  import { ChevronUp, ChevronDown, Filter } from '@carbon/icons-react';
27
 
28
  import classes from './Filters.module.scss';
29
+
30
  // ===================================================================================
31
  // TYPES
32
  // ===================================================================================
src/views/performance-overview/FilterMetrics.module.scss ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Copyright 2023-2024 InspectorRAGet Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ **/
18
+
19
+ @use '@carbon/react/scss/spacing' as *;
20
+ @use '@carbon/colors' as *;
21
+
22
+ .filterMetricsBtnTooltip {
23
+ align-self: center;
24
+ margin-bottom: $spacing-03;
25
+ }
26
+
27
+ .filterMetricsBtn {
28
+ display: flex;
29
+ column-gap: $spacing-04;
30
+ padding: $spacing-03;
31
+ color: inherit !important;
32
+ }
33
+
34
+ .filterMetricsBtnElements {
35
+ display: flex;
36
+ column-gap: $spacing-04;
37
+ align-items: center;
38
+ }
39
+
40
+ .filterMetricsBtnCaptionElements {
41
+ display: flex;
42
+ column-gap: $spacing-02;
43
+ align-items: center;
44
+ }
45
+
46
+ .container {
47
+ margin: 0 0 $spacing-03 $spacing-05;
48
+ padding: $spacing-05;
49
+ display: none;
50
+ column-gap: $spacing-09;
51
+ box-shadow: 0 0 5px 2px $gray-40;
52
+ }
53
+
54
+ .visible {
55
+ display: flex;
56
+ flex-direction: column;
57
+ align-items: center;
58
+ animation: fade-in 0.5s;
59
+ }
60
+
61
+ @keyframes fade-in {
62
+ from {
63
+ opacity: 0;
64
+ }
65
+
66
+ to {
67
+ opacity: 1;
68
+ }
69
+ }
src/views/performance-overview/FilterMetrics.tsx ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Copyright 2023-2024 InspectorRAGet Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ **/
18
+
19
+ 'use client';
20
+
21
+ import cx from 'classnames';
22
+ import { useState } from 'react';
23
+
24
+ import { FilterableMultiSelect, Tag, Tooltip, Button } from '@carbon/react';
25
+ import { ChevronUp, ChevronDown, SubtractAlt } from '@carbon/icons-react';
26
+
27
+ import { Metric } from '@/src/types';
28
+ import { extractMetricDisplayName } from '@/src/utilities/metrics';
29
+
30
+ import classes from './FilterMetrics.module.scss';
31
+
32
+ // ===================================================================================
33
+ // TYPES
34
+ // ===================================================================================
35
+ interface Props {
36
+ metrics: Metric[];
37
+ hiddenMetrics: Metric[];
38
+ setHiddenMetrics: Function;
39
+ }
40
+
41
+ export default function FilterMetrics({
42
+ metrics,
43
+ hiddenMetrics: ignoredMetrics,
44
+ setHiddenMetrics: setIgnoredMetrics,
45
+ }: Props) {
46
+ // Step 1: Initialize state and necessary variables
47
+ const [showIgnoreMetrics, setShowIgnoreMetrics] = useState<boolean>(true);
48
+
49
+ // Step 2: Render
50
+ return (
51
+ <>
52
+ <Tooltip
53
+ label={'Click to hide certain metrics'}
54
+ align={'right'}
55
+ className={classes.filterMetricsBtnTooltip}
56
+ >
57
+ <Button
58
+ id={'PerformanceOverview-metrics--Ignore'}
59
+ className={classes.filterMetricsBtn}
60
+ kind={'ghost'}
61
+ size={'sm'}
62
+ onClick={() => {
63
+ setShowIgnoreMetrics(!showIgnoreMetrics);
64
+ }}
65
+ >
66
+ <div className={classes.filterMetricsBtnElements}>
67
+ {showIgnoreMetrics ? (
68
+ <ChevronUp size={24} />
69
+ ) : (
70
+ <ChevronDown size={24} />
71
+ )}
72
+ <div className={classes.filterMetricsBtnCaptionElements}>
73
+ <h5>Hide Metrics</h5>
74
+ <SubtractAlt />
75
+ </div>
76
+ </div>
77
+ </Button>
78
+ </Tooltip>
79
+ {showIgnoreMetrics ? (
80
+ <div
81
+ className={cx(
82
+ classes.container,
83
+ showIgnoreMetrics && classes.visible,
84
+ )}
85
+ >
86
+ <FilterableMultiSelect
87
+ id={'metrics--limiter'}
88
+ items={metrics}
89
+ itemToString={(item) =>
90
+ item.displayName ? item.displayName : item.name
91
+ }
92
+ onChange={(event) => {
93
+ setIgnoredMetrics(event.selectedItems);
94
+ }}
95
+ ></FilterableMultiSelect>
96
+ <div>
97
+ {ignoredMetrics.map((metric) => {
98
+ return (
99
+ <Tag type={'cool-gray'} key={`filtered-metric--` + metric.name}>
100
+ {extractMetricDisplayName(metric)}
101
+ </Tag>
102
+ );
103
+ })}
104
+ </div>
105
+ </div>
106
+ ) : null}
107
+ </>
108
+ );
109
+ }
src/views/performance-overview/PerformanceOverview.module.scss CHANGED
@@ -52,7 +52,7 @@
52
  }
53
 
54
  .seperator {
55
- border: 1px dotted black;
56
  margin: 0 $spacing-03;
57
  }
58
 
@@ -108,7 +108,7 @@
108
  display: flex;
109
  column-gap: $spacing-03;
110
  justify-content: center;
111
- align-items: flex-end;
112
  }
113
 
114
  .warningContainerIcon {
 
52
  }
53
 
54
  .seperator {
55
+ border: 1px dotted var(--cds-border-inverse);
56
  margin: 0 $spacing-03;
57
  }
58
 
 
108
  display: flex;
109
  column-gap: $spacing-03;
110
  justify-content: center;
111
+ align-items: center;
112
  }
113
 
114
  .warningContainerIcon {
src/views/performance-overview/PerformanceOverview.tsx CHANGED
@@ -60,6 +60,7 @@ import { areObjectsIntersecting } from '@/src/utilities/objects';
60
  import { getModelColorPalette } from '@/src/utilities/colors';
61
  import AggregatorSelector from '@/src/components/selectors/AggregatorSelector';
62
  import Filters from '@/src/components/filters/Filters';
 
63
 
64
  import '@carbon/charts-react/styles.css';
65
  import classes from './PerformanceOverview.module.scss';
@@ -378,6 +379,7 @@ export default function PerformanceOverview({
378
  [key: string]: string[];
379
  }>({});
380
  const [modelColors, modelOrder] = getModelColorPalette(models);
 
381
 
382
  // Step 2: Run effects
383
  // Step 2.a: Adjust graph width & heigh based on window size
@@ -407,7 +409,7 @@ export default function PerformanceOverview({
407
  metrics.map((metric) => [metric.name, metric]),
408
  );
409
 
410
- const hData: {
411
  model: string;
412
  metric: string;
413
  score: number;
@@ -416,7 +418,7 @@ export default function PerformanceOverview({
416
  size: number;
417
  levels: { low: number; medium: number; high: number };
418
  }[] = [];
419
- const aData: {
420
  model: string;
421
  metric: string;
422
  score: number;
@@ -610,6 +612,23 @@ export default function PerformanceOverview({
610
  }
611
  }
612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
  // Step 4: Generate add rank information
614
  // Step 4.a: Human metrics
615
  if (Array.isArray(hData)) {
@@ -628,6 +647,7 @@ export default function PerformanceOverview({
628
  models,
629
  selectedAggregators,
630
  selectedFilters,
 
631
  ]);
632
 
633
  const humanMetricsInData = new Set(
@@ -684,6 +704,12 @@ export default function PerformanceOverview({
684
  />
685
  ) : null}
686
 
 
 
 
 
 
 
687
  <div
688
  className={cx(
689
  classes.row,
@@ -697,6 +723,7 @@ export default function PerformanceOverview({
697
  <h4>
698
  Human Evaluations ({numSelectedTasks}/{numTasks})
699
  </h4>
 
700
  <div className={classes.performanceTable}>
701
  {drawTable(
702
  humanMetricsData,
@@ -741,6 +768,7 @@ export default function PerformanceOverview({
741
  legend: {
742
  order: modelOrder,
743
  },
 
744
  }}
745
  ></GroupedBarChart>
746
  </>
@@ -908,7 +936,9 @@ export default function PerformanceOverview({
908
  )}
909
  </div>
910
  </div>
911
- ) : (
 
 
912
  <div className={classes.warningContainer}>
913
  <WarningAlt
914
  height={'32px'}
@@ -919,7 +949,7 @@ export default function PerformanceOverview({
919
  {`No matching evaluations found. ${!isEmpty(selectedFilters) ? 'Please try again by removing one or more additional filters.' : ''}`}
920
  </span>
921
  </div>
922
- )}
923
  </div>
924
  </div>
925
  );
 
60
  import { getModelColorPalette } from '@/src/utilities/colors';
61
  import AggregatorSelector from '@/src/components/selectors/AggregatorSelector';
62
  import Filters from '@/src/components/filters/Filters';
63
+ import FilterMetrics from '@/src/views/performance-overview/FilterMetrics';
64
 
65
  import '@carbon/charts-react/styles.css';
66
  import classes from './PerformanceOverview.module.scss';
 
379
  [key: string]: string[];
380
  }>({});
381
  const [modelColors, modelOrder] = getModelColorPalette(models);
382
+ const [hiddenMetrics, setHiddenMetrics] = useState<Metric[]>([]);
383
 
384
  // Step 2: Run effects
385
  // Step 2.a: Adjust graph width & heigh based on window size
 
409
  metrics.map((metric) => [metric.name, metric]),
410
  );
411
 
412
+ let hData: {
413
  model: string;
414
  metric: string;
415
  score: number;
 
418
  size: number;
419
  levels: { low: number; medium: number; high: number };
420
  }[] = [];
421
+ let aData: {
422
  model: string;
423
  metric: string;
424
  score: number;
 
612
  }
613
  }
614
 
615
+ // Step 3: Filter hidden metrics data
616
+ const hiddenMetricNames = hiddenMetrics.map((metric) =>
617
+ extractMetricDisplayName(metric),
618
+ );
619
+ // Step 3.a: Human metrics
620
+ if (Array.isArray(hData)) {
621
+ hData = hData.filter(
622
+ (entry) => !hiddenMetricNames.includes(entry.metric),
623
+ );
624
+ }
625
+ // Step 3.b: Algorithmic metrics
626
+ if (Array.isArray(aData)) {
627
+ aData = aData.filter(
628
+ (entry) => !hiddenMetricNames.includes(entry.metric),
629
+ );
630
+ }
631
+
632
  // Step 4: Generate add rank information
633
  // Step 4.a: Human metrics
634
  if (Array.isArray(hData)) {
 
647
  models,
648
  selectedAggregators,
649
  selectedFilters,
650
+ hiddenMetrics,
651
  ]);
652
 
653
  const humanMetricsInData = new Set(
 
704
  />
705
  ) : null}
706
 
707
+ <FilterMetrics
708
+ metrics={metrics}
709
+ hiddenMetrics={hiddenMetrics}
710
+ setHiddenMetrics={setHiddenMetrics}
711
+ />
712
+
713
  <div
714
  className={cx(
715
  classes.row,
 
723
  <h4>
724
  Human Evaluations ({numSelectedTasks}/{numTasks})
725
  </h4>
726
+
727
  <div className={classes.performanceTable}>
728
  {drawTable(
729
  humanMetricsData,
 
768
  legend: {
769
  order: modelOrder,
770
  },
771
+ theme: theme,
772
  }}
773
  ></GroupedBarChart>
774
  </>
 
936
  )}
937
  </div>
938
  </div>
939
+ ) : null}
940
+ {humanMetricsInData.size === 0 &&
941
+ algorithmicmetricsInData.size === 0 ? (
942
  <div className={classes.warningContainer}>
943
  <WarningAlt
944
  height={'32px'}
 
949
  {`No matching evaluations found. ${!isEmpty(selectedFilters) ? 'Please try again by removing one or more additional filters.' : ''}`}
950
  </span>
951
  </div>
952
+ ) : null}
953
  </div>
954
  </div>
955
  );