Skip to content

Commit

Permalink
[ML] Fix cell colour coding.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Sep 30, 2020
1 parent d5d692b commit 583aef1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const EXTENDED_NUMERICAL_TYPES = new Set([

// eslint-disable-next-line @typescript-eslint/naming-convention
export const ML__ID_COPY = 'ml__id_copy';
// eslint-disable-next-line @typescript-eslint/naming-convention
export const ML__INCREMENTAL_ID = 'ml__incremental_id';

export const isKeywordAndTextType = (fieldName: string): boolean => {
const { fields } = newJobCapsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ import { getToastNotifications } from '../../../../../util/dependency_cache';
import { getIndexData, getIndexFields, DataFrameAnalyticsConfig } from '../../../../common';
import { FEATURE_INFLUENCE } from '../../../../common/constants';
import { DEFAULT_RESULTS_FIELD } from '../../../../../../../common/constants/data_frame_analytics';
import { sortExplorationResultsFields, ML__ID_COPY } from '../../../../common/fields';
import {
sortExplorationResultsFields,
ML__ID_COPY,
ML__INCREMENTAL_ID,
} from '../../../../common/fields';

import { getFeatureCount, getOutlierScoreFieldName } from './common';

interface FeatureInfluence {
feature_name: string;
influence: number;
}

export const useOutlierData = (
indexPattern: IndexPattern | undefined,
jobConfig: DataFrameAnalyticsConfig | undefined,
Expand All @@ -61,7 +70,7 @@ export const useOutlierData = (
// reduce default selected rows from 20 to 8 for performance reasons.
8,
// by default, hide feature-influence columns and the doc id copy
(d) => !d.includes(`.${FEATURE_INFLUENCE}.`) && d !== ML__ID_COPY
(d) => !d.includes(`.${FEATURE_INFLUENCE}.`) && d !== ML__ID_COPY && d !== ML__INCREMENTAL_ID
);

useEffect(() => {
Expand Down Expand Up @@ -138,9 +147,16 @@ export const useOutlierData = (
// column with feature values get color coded by its corresponding influencer value
if (
fullItem[resultsField] !== undefined &&
fullItem[resultsField][`${FEATURE_INFLUENCE}.${columnId}`] !== undefined
fullItem[resultsField][FEATURE_INFLUENCE] !== undefined &&
fullItem[resultsField][FEATURE_INFLUENCE].find(
(d: FeatureInfluence) => d.feature_name === columnId
) !== undefined
) {
backgroundColor = colorRange(fullItem[resultsField][`${FEATURE_INFLUENCE}.${columnId}`]);
backgroundColor = colorRange(
fullItem[resultsField][FEATURE_INFLUENCE].find(
(d: FeatureInfluence) => d.feature_name === columnId
).influence
);
}

// column with influencer values get color coded by its own value
Expand Down

0 comments on commit 583aef1

Please sign in to comment.