Skip to content

Commit

Permalink
[ML] Fix values for decision path not showing correctly for regressio…
Browse files Browse the repository at this point in the history
…n due to rounding #80448 (#80555)
  • Loading branch information
qn895 authored Oct 14, 2020
1 parent fb9ccc0 commit 808293a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import React, { useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import euiVars from '@elastic/eui/dist/eui_theme_light.json';
import { DecisionPathPlotData } from './use_classification_path_data';
import { formatSingleValue } from '../../../formatters/format_value';

const { euiColorFullShade, euiColorMediumShade } = euiVars;
const axisColor = euiColorMediumShade;
Expand Down Expand Up @@ -79,7 +80,6 @@ interface DecisionPathChartProps {

const DECISION_PATH_MARGIN = 125;
const DECISION_PATH_ROW_HEIGHT = 10;
const NUM_PRECISION = 3;
const AnnotationBaselineMarker = <EuiIcon type="dot" size="m" />;

export const DecisionPathChart = ({
Expand All @@ -95,7 +95,7 @@ export const DecisionPathChart = ({
() => [
{
dataValue: baseline,
header: baseline ? baseline.toPrecision(NUM_PRECISION) : '',
header: baseline ? formatSingleValue(baseline).toString() : '',
details: i18n.translate(
'xpack.ml.dataframe.analytics.explorationResults.decisionPathBaselineText',
{
Expand All @@ -110,7 +110,7 @@ export const DecisionPathChart = ({
// if regression, guarantee up to num_precision significant digits without having it in scientific notation
// if classification, hide the numeric values since we only want to show the path
const tickFormatter = useCallback(
(d) => (showValues === false ? '' : Number(d.toPrecision(NUM_PRECISION)).toString()),
(d) => (showValues === false ? '' : formatSingleValue(d).toString()),
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export function formatValue(
// For time_of_day or time_of_week functions the anomaly record
// containing the timestamp of the anomaly should be supplied in
// order to correctly format the day or week offset to the time of the anomaly.
function formatSingleValue(
export function formatSingleValue(
value: number,
mlFunction: string,
mlFunction?: string,
fieldFormat?: any,
record?: AnomalyRecordDoc
) {
Expand Down

0 comments on commit 808293a

Please sign in to comment.