Skip to content

Commit

Permalink
[ML] Fixes incorrect feature importance visualization for Data Frame …
Browse files Browse the repository at this point in the history
…Analytics classification (elastic#150816)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit c2476d2)
  • Loading branch information
qn895 committed Feb 14, 2023
1 parent 3aaa46a commit 6b3e561
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const DataGrid: FC<Props> = memo(
analysisType === ANALYSIS_CONFIG_TYPE.OUTLIER_DETECTION
) {
if (schema === 'featureImportance') {
const row = data[rowIndex];
const row = data[rowIndex - pagination.pageIndex * pagination.pageSize];
if (!row) return <div />;
// if resultsField for some reason is not available then use ml
const mlResultsField = resultsField ?? DEFAULT_RESULTS_FIELD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
} from '../../../../../../../common/types/feature_importance';
import { DecisionPathChart } from './decision_path_chart';
import { MissingDecisionPathCallout } from './missing_decision_path_callout';
import { TopClass } from '../../../../../../../common/types/feature_importance';

interface ClassificationDecisionPathProps {
predictedValue: string | boolean;
Expand All @@ -42,12 +43,20 @@ export const ClassificationDecisionPath: FC<ClassificationDecisionPathProps> = (
const [currentClass, setCurrentClass] = useState<string>(
getStringBasedClassName(topClasses[0].class_name)
);
const selectedClass = topClasses.find(
(t) => getStringBasedClassName(t.class_name) === getStringBasedClassName(currentClass)
) as TopClass;
const predictedProbabilityForCurrentClass = selectedClass
? selectedClass.class_probability
: undefined;

const { decisionPathData } = useDecisionPathData({
baseline,
featureImportance,
predictedValue: currentClass,
predictedProbability,
predictedProbability: predictedProbabilityForCurrentClass,
});

const options = useMemo(() => {
const predictionValueStr = getStringBasedClassName(predictedValue);

Expand Down
Loading

0 comments on commit 6b3e561

Please sign in to comment.