-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathAUCChart.tsx
More file actions
58 lines (52 loc) · 1.64 KB
/
AUCChart.tsx
File metadata and controls
58 lines (52 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Stack, StackItem, getTheme } from "@fluentui/react";
import {
BasicHighChart,
IDataset,
ILabeledStatistic,
ITelemetryEvent,
ModelAssessmentContext,
calculateAUCData,
defaultModelAssessmentContext
} from "@responsible-ai/core-ui";
import React from "react";
import { getAUCChartOptions } from "./getAUCChartOptions";
import { modelOverviewChartStyles } from "./ModelOverviewChart.styles";
interface IAUCChartProps {
dataset: IDataset;
cohortStats: ILabeledStatistic[][];
telemetryHook?: (message: ITelemetryEvent) => void;
}
export class AUCChart extends React.PureComponent<IAUCChartProps> {
public static contextType = ModelAssessmentContext;
public context: React.ContextType<typeof ModelAssessmentContext> =
defaultModelAssessmentContext;
public render(): React.ReactNode {
const theme = getTheme();
const classNames = modelOverviewChartStyles();
if (
this.context.dataset.predicted_y === undefined ||
this.context.dataset.true_y === undefined
) {
return React.Fragment;
}
const yLength = this.context.dataset.predicted_y.length;
if (this.context.dataset.true_y.length !== yLength) {
return React.Fragment;
}
const allData = calculateAUCData(this.props.dataset);
const plotData = getAUCChartOptions(allData, theme);
return (
<Stack id="modelOverviewAUCChart">
<StackItem className={classNames.chart}>
<BasicHighChart
configOverride={plotData}
theme={theme}
id="AUCChart"
/>
</StackItem>
</Stack>
);
}
}