Skip to content

Commit

Permalink
Merge branch 'main' into gaugup/AddPreBuiltInjectionIntoRAIWidgets
Browse files Browse the repository at this point in the history
  • Loading branch information
gaugup authored Feb 23, 2022
2 parents ac536c5 + ede5f43 commit f67e1b9
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 24 deletions.
1 change: 1 addition & 0 deletions libs/core-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ export * from "./lib/Interfaces/IFilter";
export * from "./lib/Interfaces/ICohort";
export * from "./lib/Interfaces/IErrorAnalysisData";
export * from "./lib/Highchart/BasicHighChart";
export * from "./lib/Highchart/FeatureImportanceDependence";
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
IProcessedStyleSet,
mergeStyleSets,
IStyle
} from "office-ui-fabric-react";

export interface IDependencePlotStyles {
DependencePlot: IStyle;
chartWithAxes: IStyle;
chart: IStyle;
chartWithVertical: IStyle;
verticalAxis: IStyle;
rotatedVerticalBox: IStyle;
horizontalAxisWithPadding: IStyle;
paddingDiv: IStyle;
horizontalAxis: IStyle;
placeholderWrapper: IStyle;
placeholder: IStyle;
secondaryChartPlacolderBox: IStyle;
secondaryChartPlacolderSpacer: IStyle;
faintText: IStyle;
}

export const dependencePlotStyles: () => IProcessedStyleSet<IDependencePlotStyles> =
() => {
return mergeStyleSets<IDependencePlotStyles>({
chart: {
flex: 1,
height: "100%"
},
chartWithAxes: {
display: "flex",
flex: "1",
flexDirection: "column",
padding: "5px 20px 0 20px"
},
chartWithVertical: {
display: "flex",
flexDirection: "row",
height: "400px",
width: "100%"
},
DependencePlot: {
display: "flex",
flexDirection: "row",
flexGrow: "1"
},
faintText: {
fontWeight: "350" as any
},
horizontalAxis: {
flex: 1,
textAlign: "center"
},
horizontalAxisWithPadding: {
display: "flex",
flexDirection: "row"
},
paddingDiv: {
width: "50px"
},
placeholder: {
maxWidth: "70%"
},
placeholderWrapper: {
margin: "100px auto 0 auto"
},
rotatedVerticalBox: {
marginLeft: "15px",
position: "absolute",
textAlign: "center",
top: "50%",
transform: "translateX(-50%) translateY(-50%) rotate(270deg)",
width: "max-content"
},
secondaryChartPlacolderBox: {
flex: 1,
height: "400px"
},
secondaryChartPlacolderSpacer: {
boxShadow: "0px 0px 6px rgba(0, 0, 0, 0.2)",
margin: "25px auto 0 auto",
padding: "23px",
width: "fit-content"
},
verticalAxis: {
height: "auto",
position: "relative",
top: "0px",
width: "50px"
}
});
};
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
Cohort,
JointDataset,
IExplanationModelMetadata,
ModelTypes,
WeightVectorOption,
IGenericChartProps,
BasicHighChart,
getDependencyChartOptions
} from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import _ from "lodash";
import { getTheme, Text } from "office-ui-fabric-react";
import React from "react";

import { getDependenceData } from "../../utils/getDependenceData";
import { Cohort } from "../Cohort/Cohort";
import {
IExplanationModelMetadata,
ModelTypes
} from "../Interfaces/IExplanationContext";
import { WeightVectorOption } from "../Interfaces/IWeightedDropdownContext";
import { FabricStyles } from "../util/FabricStyles";
import { getDependenceData } from "../util/getDependenceData";
import { getDependencyChartOptions } from "../util/getDependencyChartOptions";
import { IGenericChartProps } from "../util/IGenericChartProps";
import { JointDataset } from "../util/JointDataset";

import { dependencePlotStyles } from "./DependencePlot.styles";
import { BasicHighChart } from "./BasicHighChart";
import { dependencePlotStyles } from "./FeatureImportanceDependence.styles";

export interface IDependencyHighChartProps {
export interface IFeatureImportanceDependenceProps {
chartProps: IGenericChartProps | undefined;
jointDataset: JointDataset;
cohort: Cohort;
Expand All @@ -31,7 +32,7 @@ export interface IDependencyHighChartProps {
onChange: (props: IGenericChartProps) => void;
}

export class DependencyHighChart extends React.PureComponent<IDependencyHighChartProps> {
export class FeatureImportanceDependence extends React.PureComponent<IFeatureImportanceDependenceProps> {
public render(): React.ReactNode {
const classNames = dependencePlotStyles();
if (this.props.chartProps === undefined) {
Expand Down Expand Up @@ -77,6 +78,7 @@ export class DependencyHighChart extends React.PureComponent<IDependencyHighChar
this.props.jointDataset.metaDict[
this.props.chartProps.xAxis.property
].sortedCategoricalValues,
FabricStyles.fabricColorPalette[this.props.cohortIndex],
getTheme()
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
Cohort,
IDependenceData,
IGenericChartProps,
JointDataset
} from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import _, { Dictionary } from "lodash";

import { Cohort } from "../Cohort/Cohort";

import { IDependenceData } from "./getDependencyChartOptions";
import { IGenericChartProps } from "./IGenericChartProps";
import { JointDataset } from "./JointDataset";

export function getDependenceData(
chartProps: IGenericChartProps | undefined,
jointData: JointDataset,
Expand Down
3 changes: 2 additions & 1 deletion libs/core-ui/src/lib/util/getDependencyChartOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IDependenceData {
export function getDependencyChartOptions(
data: IDependenceData[],
xLabels: string[] | undefined,
pointColor: string,
theme?: ITheme
): IHighchartsConfig {
const colorTheme = {
Expand Down Expand Up @@ -45,7 +46,7 @@ export function getDependencyChartOptions(
},
series: [
{
color: colorTheme.fontColor,
color: pointColor,
data,
name: "",
type: "scatter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
defaultModelAssessmentContext,
ModelAssessmentContext,
FabricStyles,
LabelWithCallout
LabelWithCallout,
FeatureImportanceDependence
} from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import { Dictionary } from "lodash";
Expand All @@ -28,7 +29,6 @@ import {
} from "office-ui-fabric-react";
import React from "react";

import { DependencyHighChart } from "../DependencePlot/DependencyHighChart";
import { explainerCalloutDictionary } from "../ExplainerCallouts/explainerCalloutDictionary";
import { FeatureImportanceBar } from "../FeatureImportanceBar/FeatureImportanceBar";
import { GlobalOnlyChart } from "../GlobalOnlyChart/GlobalOnlyChart";
Expand Down Expand Up @@ -255,7 +255,7 @@ export class GlobalExplanationTab extends React.PureComponent<
className={classNames.secondaryChartAndLegend}
ref={this.depPlot}
>
<DependencyHighChart
<FeatureImportanceDependence
chartProps={this.state.dependenceProps}
cohortIndex={this.state.selectedCohortIndex}
cohort={this.props.cohorts[this.state.selectedCohortIndex]}
Expand Down

0 comments on commit f67e1b9

Please sign in to comment.