Skip to content

Commit

Permalink
add text feature importance e2e unit tests for blbooksgenre jupyter n…
Browse files Browse the repository at this point in the history
…otebook (microsoft#2327)
  • Loading branch information
imatiach-msft authored Sep 12, 2023
1 parent 615d68e commit eae21b7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
describeModelAssessmentTextFeatureImportance,
modelAssessmentDatasets
} from "@responsible-ai/e2e";

const datasetShape =
modelAssessmentDatasets.BlbooksgenreTextClassificationModelDebugging;
describeModelAssessmentTextFeatureImportance(
datasetShape,
"BlbooksgenreTextClassificationModelDebugging"
);
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface IInterpretTextData {
positiveFeaturesExpectedValues: number;
};
explanationIndex: number;
expandCorrect?: boolean;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { textExplanationData } from "./BlbooksgenreTextExplanationData";

export const BlbooksgenreTextClassificationModelDebugging = {
causalAnalysisData: {
hasCausalAnalysisComponent: false
Expand Down Expand Up @@ -48,5 +50,6 @@ export const BlbooksgenreTextClassificationModelDebugging = {
name: "CohortCreateE2E-text-classification",
sampleSize: "19"
}
}
},
textExplanationData
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

const localExplanationData = [
[0, 0],
[-0.005633711814880371, 0.005633684573695064],
[-0.016269147396087646, 0.016269136918708682],
[-0.010049201548099518, 0.010049237171187997],
[0.009819332510232925, -0.009819337516091764],
[0.05134781077504158, -0.05134780355729163],
[-0.013548329472541809, 0.01354830723721534],
[0.004447728395462036, -0.004447765881195664],
[0, 0]
];

export const textExplanationData = {
classNames: ["0", "1"],
expandCorrect: true,
expectedFeaturesValues: {
allFeaturesExpectedValues: 3,
negativeFeaturesExpectedValues: 3,
positiveFeaturesExpectedValues: 3
},
explanationIndex: 19,
localExplanations: localExplanationData,
text: ["", "Maximilian", ", ", "and ", "other ", "poems", ", ", "etc", ""]
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function describeModelAssessmentTextFeatureImportance(
if (datasetShape.textExplanationData) {
const textExplanationData = datasetShape.textExplanationData;
it("should be able to select a table row for testing", () => {
if (textExplanationData.expandCorrect) {
cy.get(Locators.IFICollapseButton).first().click();
}
selectRow(
"Index",
textExplanationData.explanationIndex.toString(),
Expand Down

0 comments on commit eae21b7

Please sign in to comment.