Skip to content

Commit

Permalink
[ML] Fix cell value.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Oct 29, 2020
1 parent 4266638 commit 31239b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
KBN_FIELD_TYPES,
} from '../../../../../../../src/plugins/data/public';

import { DEFAULT_RESULTS_FIELD } from '../../../../common/constants/data_frame_analytics';
import { extractErrorMessage } from '../../../../common/util/errors';
import { FeatureImportance, TopClasses } from '../../../../common/types/feature_importance';

Expand Down Expand Up @@ -252,6 +253,15 @@ export const useRenderCellValue = (
return item[cId];
}

// For classification and regression results, we need to treat some fields with a custom transform.
if (cId === `${resultsField}.feature_importance`) {
return getFeatureImportance(fullItem, resultsField ?? DEFAULT_RESULTS_FIELD);
}

if (cId === `${resultsField}.top_classes`) {
return getTopClasses(fullItem, resultsField ?? DEFAULT_RESULTS_FIELD);
}

// Try if the field name is available as a nested field.
return getNestedProperty(tableItems[adjustedRowIndex], cId, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export const getDefaultFieldsFromJobCaps = (
name: `${resultsField}.${FEATURE_IMPORTANCE}`,
type: KBN_FIELD_TYPES.UNKNOWN,
});
// remove flattened feature importance fields
fields = fields.filter(
(field: any) => !field.name.includes(`${resultsField}.${FEATURE_IMPORTANCE}.`)
);
}

if ((numTopClasses ?? 0) > 0) {
Expand All @@ -221,6 +225,10 @@ export const getDefaultFieldsFromJobCaps = (
name: `${resultsField}.${TOP_CLASSES}`,
type: KBN_FIELD_TYPES.UNKNOWN,
});
// remove flattened top classes fields
fields = fields.filter(
(field: any) => !field.name.includes(`${resultsField}.${TOP_CLASSES}.`)
);
}

// Only need to add these fields if we didn't use dest index pattern to get the fields
Expand Down

0 comments on commit 31239b6

Please sign in to comment.