Skip to content

Commit

Permalink
[ML] DF Analytics Classification: clarify subset of data used in conf…
Browse files Browse the repository at this point in the history
…usion matrix (#61548) (#61852)

* clarify which subset of data is being used in confusion matrix

* ensure dataSubsetTitle updates correctly
  • Loading branch information
alvarezmelissa87 authored Mar 31, 2020
1 parent 3dc2ea7 commit f1d038b
Showing 1 changed file with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@ interface Props {
searchQuery: ResultsSearchQuery;
}

enum SUBSET_TITLE {
TRAINING = 'training',
TESTING = 'testing',
ENTIRE = 'entire',
}

const entireDatasetHelpText = i18n.translate(
'xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixEntireHelpText',
{
defaultMessage: 'Normalized confusion matrix for entire dataset',
}
);

const testingDatasetHelpText = i18n.translate(
'xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTestingHelpText',
{
defaultMessage: 'Normalized confusion matrix for testing dataset',
}
);

const trainingDatasetHelpText = i18n.translate(
'xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTrainingHelpText',
{
defaultMessage: 'Normalized confusion matrix for training dataset',
}
);

function getHelpText(dataSubsetTitle: string) {
let helpText = entireDatasetHelpText;
if (dataSubsetTitle === SUBSET_TITLE.TESTING) {
helpText = testingDatasetHelpText;
} else if (dataSubsetTitle === SUBSET_TITLE.TRAINING) {
helpText = trainingDatasetHelpText;
}
return helpText;
}

export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery }) => {
const {
services: { docLinks },
Expand All @@ -66,6 +103,7 @@ export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery })
const [popoverContents, setPopoverContents] = useState<any>([]);
const [docsCount, setDocsCount] = useState<null | number>(null);
const [error, setError] = useState<null | string>(null);
const [dataSubsetTitle, setDataSubsetTitle] = useState<SUBSET_TITLE>(SUBSET_TITLE.ENTIRE);
const [panelWidth, setPanelWidth] = useState<number>(defaultPanelWidth);
// Column visibility
const [visibleColumns, setVisibleColumns] = useState(() =>
Expand Down Expand Up @@ -197,6 +235,18 @@ export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery })
hasIsTrainingClause[0] &&
hasIsTrainingClause[0].match[`${resultsField}.is_training`];

const noTrainingQuery = isTrainingClause === false || isTrainingClause === undefined;

if (noTrainingQuery) {
setDataSubsetTitle(SUBSET_TITLE.ENTIRE);
} else {
setDataSubsetTitle(
isTrainingClause && isTrainingClause.query === 'true'
? SUBSET_TITLE.TRAINING
: SUBSET_TITLE.TESTING
);
}

loadData({ isTrainingClause });
}, [JSON.stringify(searchQuery)]);

Expand Down Expand Up @@ -302,14 +352,7 @@ export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery })
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="xs">
<EuiTitle size="xxs">
<span>
{i18n.translate(
'xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixHelpText',
{
defaultMessage: 'Normalized confusion matrix',
}
)}
</span>
<span>{getHelpText(dataSubsetTitle)}</span>
</EuiTitle>
<EuiFlexItem grow={false}>
<EuiIconTip
Expand Down

0 comments on commit f1d038b

Please sign in to comment.