Skip to content

Commit

Permalink
[ML] Use doc links service for more ML pages (elastic#86405)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Dec 22, 2020
1 parent 96fa0db commit 456a1af
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const DecisionPathPopover: FC<DecisionPathPopoverProps> = ({
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docLink = docLinks.links.ml.featureImportance;

if (featureImportance.length < 2) {
return <DecisionPathJSONViewer featureImportance={featureImportance} />;
Expand Down Expand Up @@ -106,10 +106,7 @@ export const DecisionPathPopover: FC<DecisionPathPopoverProps> = ({
values={{
predictionFieldName,
linkedFeatureImportanceValues: (
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-feature-importance.html`}
target="_blank"
>
<EuiLink href={docLink} target="_blank">
<FormattedMessage
id="xpack.ml.dataframe.analytics.explorationResults.linkedFeatureImportanceValues"
defaultMessage="feature importance values"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ const numClassesTypeMessage = (
/>
);

function getZeroClassesMessage(elasaticUrl: string, version: string) {
function getZeroClassesMessage(elasticUrl: string) {
return (
<FormattedMessage
id="xpack.ml.dataframe.analytics.create.zeroClassesMessage"
defaultMessage="To evaluate the {wikiLink}, select all classes or a value greater than the total number of categories."
values={{
wikiLink: (
<EuiLink
href={`${elasaticUrl}guide/en/machine-learning/${version}/ml-dfanalytics-evaluate.html#ml-dfanalytics-roc`}
target="_blank"
external
>
<EuiLink href={elasticUrl} target="_blank" external>
{i18n.translate('xpack.ml.dataframe.analytics.create.aucRocLabel', {
defaultMessage: 'AUC ROC',
})}
Expand Down Expand Up @@ -136,7 +132,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const classAucRocDocLink = docLinks.links.ml.classificationAucRoc;

const { setEstimatedModelMemoryLimit, setFormState } = actions;
const { form, isJobCreated, estimatedModelMemoryLimit } = state;
Expand Down Expand Up @@ -422,9 +418,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
helpText={getTopClassesHelpText(selectedNumTopClasses)}
isInvalid={selectedNumTopClasses === 0 || selectedNumTopClassesIsInvalid}
error={[
...(selectedNumTopClasses === 0
? [getZeroClassesMessage(ELASTIC_WEBSITE_URL, DOC_LINK_VERSION)]
: []),
...(selectedNumTopClasses === 0 ? [getZeroClassesMessage(classAucRocDocLink)] : []),
...(selectedNumTopClassesIsInvalid ? [numClassesTypeMessage] : []),
]}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const EvaluatePanel: FC<EvaluatePanelProps> = ({ jobConfig, jobStatus, se
return <span>{columnId === ACTUAL_CLASS_ID ? cellValue : accuracy}</span>;
};

const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docLink = docLinks.links.ml.classificationEvaluation;

const showTrailingColumns = columnsData.length > MAX_COLUMNS;
const extraColumns = columnsData.length - MAX_COLUMNS;
Expand Down Expand Up @@ -300,7 +300,7 @@ export const EvaluatePanel: FC<EvaluatePanelProps> = ({ jobConfig, jobStatus, se
iconType="help"
iconSide="left"
color="primary"
href={`${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-dfanalytics-evaluate.html#ml-dfanalytics-classification`}
href={docLink}
>
{i18n.translate(
'xpack.ml.dataframe.analytics.classificationExploration.classificationDocsLink',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery })
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docLink = docLinks.links.ml.regressionEvaluation;
const [trainingEval, setTrainingEval] = useState<Eval>(defaultEval);
const [generalizationEval, setGeneralizationEval] = useState<Eval>(defaultEval);
const [isLoadingTraining, setIsLoadingTraining] = useState<boolean>(false);
Expand Down Expand Up @@ -236,7 +236,7 @@ export const EvaluatePanel: FC<Props> = ({ jobConfig, jobStatus, searchQuery })
iconType="help"
iconSide="left"
color="primary"
href={`${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-dfanalytics-evaluate.html#ml-dfanalytics-regression-evaluation`}
href={docLink}
>
{i18n.translate(
'xpack.ml.dataframe.analytics.regressionExploration.regressionDocsLink',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const FeatureImportanceSummaryPanel: FC<FeatureImportanceSummaryPanelProp
return [sortedData, _barSeriesSpec, _showLegend, _chartHeight];
}, [totalFeatureImportance]);

const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docLink = docLinks.links.ml.featureImportance;
const tickFormatter = useCallback((d) => Number(d.toPrecision(3)).toString(), []);

// do not expand by default if no feature importance data
Expand Down Expand Up @@ -256,7 +256,7 @@ export const FeatureImportanceSummaryPanel: FC<FeatureImportanceSummaryPanelProp
iconType="help"
iconSide="left"
color="primary"
href={`${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-feature-importance.html`}
href={docLink}
>
<FormattedMessage
id="xpack.ml.dataframe.analytics.exploration.featureImportanceDocsLink"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const Description: FC = memo(({ children }) => {
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docsUrl = `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-calendars.html`;
const docsUrl = docLinks.links.ml.calendars;
const title = i18n.translate(
'xpack.ml.newJob.wizard.jobDetailsStep.additionalSection.calendarsSelection.title',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const Description: FC = memo(({ children }) => {
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docsUrl = `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-configuring-url.html`;
const docsUrl = docLinks.links.ml.customUrls;
const title = i18n.translate(
'xpack.ml.newJob.wizard.jobDetailsStep.additionalSection.customUrls.title',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const Description: FC<Props> = memo(({ children, validation }) => {
const {
services: { docLinks },
} = useMlKibana();
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docsUrl = `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/ml-configuring-aggregation.html`;
const docsUrl = docLinks.links.ml.aggregations;
return (
<EuiDescribedFormGroup
title={<h3>{title}</h3>}
Expand Down

0 comments on commit 456a1af

Please sign in to comment.