From a9515bd9320f80542431faa86e74148af86b2250 Mon Sep 17 00:00:00 2001
From: Melissa Alvarez <melissa.alvarez@elastic.co>
Date: Wed, 16 Oct 2019 09:12:42 -0400
Subject: [PATCH] [ML] DF Analytics fix: show MSE and rSquared in expanded row
 only for regression jobs (#48390)

* Only show MSE and rSquared in expanded row for regression jobs

* use isRegressionAnalysis check
---
 .../components/analytics_list/expanded_row.tsx              | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/expanded_row.tsx b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/expanded_row.tsx
index ab8ef81c593a2..67bad23adacf6 100644
--- a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/expanded_row.tsx
+++ b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/expanded_row.tsx
@@ -20,6 +20,7 @@ import { ExpandedRowJsonPane } from './expanded_row_json_pane';
 import { ProgressBar } from './progress_bar';
 import { getDependentVar, getValuesFromResponse, loadEvalData, Eval } from '../../../../common';
 import { isCompletedAnalyticsJob } from './common';
+import { isRegressionAnalysis } from '../../../../common/analytics';
 // import { ExpandedRowMessagesPane } from './expanded_row_messages_pane';
 
 function getItemDescription(value: any) {
@@ -60,6 +61,7 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
   const index = idx(item, _ => _.config.dest.index) as string;
   const dependentVariable = getDependentVar(item.config.analysis);
   const jobIsCompleted = isCompletedAnalyticsJob(item.stats);
+  const isRegressionJob = isRegressionAnalysis(item.config.analysis);
 
   const loadData = async () => {
     setIsLoadingGeneralization(true);
@@ -113,7 +115,7 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
   };
 
   useEffect(() => {
-    if (jobIsCompleted) {
+    if (jobIsCompleted && isRegressionJob) {
       loadData();
     }
   }, [jobIsCompleted]);
@@ -162,7 +164,7 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
     position: 'right',
   };
 
-  if (jobIsCompleted) {
+  if (jobIsCompleted && isRegressionJob) {
     stats.items.push(
       {
         title: 'generalization mean squared error',