Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Overview: Object Detection Widgets for Aggregate Methods, Class selection, & IoU Threshold #1997

Merged
merged 19 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/localization/src/lib/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,8 @@
"macro": "Macro",
"micro": "Micro"
},
"classSelectionDropdown": "Select class(es)",
"iouthresholdDropdown": "IoU Threshold",
"notAvailable": "N/A",
"countColumnHeader": "Sample size",
"dataCohortsHeatmapHeader": "Cohorts",
Expand All @@ -1773,6 +1775,7 @@
"probabilityForClassSelectionHeader": "Probability for class",
"targetSelectionHeader": "Target",
"metricSelectionDropdownPlaceholder": "Select metrics to compare your cohorts.",
"classSelectionDropdownPlaceholder": "Select class name for class-based analysis.",
"featureSelectionDropdownPlaceholder": "Select features to use for a feature-based analysis.",
"probabilityDistributionPivotItem": "Probability distribution",
"regressionDistributionPivotItem": "Target distribution",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface IModelOverviewStyles {
generalText: IStyle;
generalSemiBoldText: IStyle;
selections: IStyle;
slider: IStyle;
smallDropdown: IStyle;
tabs: IStyle;
}
Expand Down Expand Up @@ -53,6 +54,9 @@ export const modelOverviewStyles: () => IProcessedStyleSet<IModelOverviewStyles>
padding: "0 40px 32px 40px"
},
selections: flexLgDown,
slider: {
width: "250px"
Advitya17 marked this conversation as resolved.
Show resolved Hide resolved
},
smallDropdown: {
width: "150px"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { FeatureConfigurationFlyout } from "./FeatureConfigurationFlyout";
import { MetricConfigurationFlyout } from "./MetricConfigurationFlyout";
import { modelOverviewStyles } from "./ModelOverview.styles";
import { ModelOverviewChartPivot } from "./ModelOverviewChartPivot";
import { ObjectDetectionWidgets } from "./ObjectDetectionModelOverview";
import { getSelectableMetrics } from "./StatsTableUtils";

interface IModelOverviewProps {
Expand Down Expand Up @@ -327,6 +328,13 @@ export class ModelOverview extends React.Component<
.helpMeChooseMetricsButton
}
</ActionButton>
{this.context.dataset.task_type ===
DatasetTaskType.ObjectDetection && (
<ObjectDetectionWidgets
classNames={classNames}
dataset={this.context.dataset}
/>
)}
</Stack>
{!this.state.datasetCohortViewIsVisible && (
<Stack
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
ComboBox,
IComboBoxOption,
IProcessedStyleSet,
Slider,
Stack
} from "@fluentui/react";
import { FluentUIStyles, IDataset } from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import React from "react";

import { IModelOverviewStyles } from "./ModelOverview.styles";

export function getSelectableAggregateMethod(): IComboBoxOption[] {
const selectableAggregateMethods: IComboBoxOption[] = [
{
key: "macro",
text: localization.ModelAssessment.ModelOverview.metricTypes.macro
},
{
key: "micro",
text: localization.ModelAssessment.ModelOverview.metricTypes.micro
}
];
return selectableAggregateMethods;
}

export function getSelectableClassNames(dataset: IDataset): IComboBoxOption[] {
const selectableClassNames: IComboBoxOption[] = [];
if (dataset.class_names) {
for (const className of dataset.class_names) {
selectableClassNames.push({
key: className,
text: className
});
}
}
return selectableClassNames;
}

export interface IObjectDetectionWidgetsProps {
classNames: IProcessedStyleSet<IModelOverviewStyles>;
dataset: IDataset;
}

export class ObjectDetectionWidgets extends React.PureComponent<IObjectDetectionWidgetsProps> {
public render(): React.ReactNode {
return (
<Stack.Item>
<ComboBox
id="modelOverviewAggregateMethod"
label={localization.ModelAssessment.ModelOverview.metricsTypeDropdown}
selectedKey={"macro"}
options={getSelectableAggregateMethod()}
className={this.props.classNames.dropdown}
styles={FluentUIStyles.smallDropdownStyle}
/>
<ComboBox
id="modelOverviewClassSelection"
placeholder={
localization.ModelAssessment.ModelOverview
.classSelectionDropdownPlaceholder
}
label={
localization.ModelAssessment.ModelOverview.classSelectionDropdown
}
options={getSelectableClassNames(this.props.dataset)}
className={this.props.classNames.dropdown}
styles={FluentUIStyles.smallDropdownStyle}
/>
<Slider
id="iouThreshold"
label={
localization.ModelAssessment.ModelOverview.iouthresholdDropdown
}
max={100}
className={this.props.classNames.slider}
valueFormat={(value: number): string => `IoU=${value}%`}
showValue
/>
</Stack.Item>
);
}
}