Transformations: Rename Regression Analysis to Trendline (#108631)
* Rename regression analysis transformation * fix a couple translations * remove extra word * Fix tests * Change frame name to use regression
This commit is contained in:
@@ -1483,17 +1483,19 @@ If you have multiple types it will default to string type.
|
||||
|
||||
{{< figure src="/media/docs/grafana/transformations/screenshot-grafana-11-2-transpose-transformation.png" class="docs-image--no-shadow" max-width= "1100px" alt="Before and after transpose transformation" >}}
|
||||
|
||||
### Regression analysis
|
||||
### Trendline
|
||||
|
||||
Use this transformation to create a new data frame containing values predicted by a statistical model. This is useful for finding a trend in chaotic data. It works by fitting a mathematical function to the data, using either linear or polynomial regression. The data frame can then be used in a visualization to display a trendline.
|
||||
|
||||
There are two different models:
|
||||
|
||||
- **Linear regression** - Fits a linear function to the data.
|
||||
- **Linear** - Fits a linear function to the data.
|
||||
{{< figure src="/static/img/docs/transformations/linear-regression.png" class="docs-image--no-shadow" max-width= "1100px" alt="A time series visualization with a straight line representing the linear function" >}}
|
||||
- **Polynomial regression** - Fits a polynomial function to the data.
|
||||
- **Polynomial** - Fits a polynomial function to the data.
|
||||
{{< figure src="/static/img/docs/transformations/polynomial-regression.png" class="docs-image--no-shadow" max-width= "1100px" alt="A time series visualization with a curved line representing the polynomial function" >}}
|
||||
|
||||
> **Note:** This transformation was previously called regression analysis.
|
||||
|
||||
[Table panel]: ref:table-panel
|
||||
[Calculation types]: ref:calculation-types
|
||||
[sparkline cell type]: ref:sparkline-cell-type
|
||||
|
||||
@@ -1584,25 +1584,27 @@ ${buildImageContent(
|
||||
},
|
||||
},
|
||||
regression: {
|
||||
name: 'Regression analysis',
|
||||
name: 'Trendline',
|
||||
getHelperDocs: function (imageRenderType: ImageRenderType = ImageRenderType.ShortcodeFigure) {
|
||||
return `
|
||||
Use this transformation to create a new data frame containing values predicted by a statistical model. This is useful for finding a trend in chaotic data. It works by fitting a mathematical function to the data, using either linear or polynomial regression. The data frame can then be used in a visualization to display a trendline.
|
||||
|
||||
There are two different models:
|
||||
|
||||
- **Linear regression** - Fits a linear function to the data.
|
||||
- **Linear** - Fits a linear function to the data.
|
||||
${buildImageContent(
|
||||
'/static/img/docs/transformations/linear-regression.png',
|
||||
imageRenderType,
|
||||
'A time series visualization with a straight line representing the linear function'
|
||||
)}
|
||||
- **Polynomial regression** - Fits a polynomial function to the data.
|
||||
- **Polynomial** - Fits a polynomial function to the data.
|
||||
${buildImageContent(
|
||||
'/static/img/docs/transformations/polynomial-regression.png',
|
||||
imageRenderType,
|
||||
'A time series visualization with a curved line representing the polynomial function'
|
||||
)}
|
||||
|
||||
> **Note:** This transformation was previously called regression analysis.
|
||||
`;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
import { ModelType, getRegressionTransformer, RegressionTransformerOptions } from './regression';
|
||||
|
||||
describe('Regression transformation', () => {
|
||||
describe('Trendline transformation', () => {
|
||||
const RegressionTransformer = getRegressionTransformer();
|
||||
|
||||
it('it should predict a linear regression to exactly fit the data when the data is f(x) = x', () => {
|
||||
@@ -47,7 +47,7 @@ describe('Regression transformation', () => {
|
||||
name: 'Linear regression',
|
||||
fields: [
|
||||
{ name: 'time', type: FieldType.time, values: [0, 1, 2, 3, 4, 5], config: {} },
|
||||
{ name: 'value predicted', type: FieldType.number, values: [0, 1, 2, 3, 4, 5], config: {} },
|
||||
{ name: 'value', type: FieldType.number, values: [0, 1, 2, 3, 4, 5], config: {} },
|
||||
],
|
||||
length: 6,
|
||||
}),
|
||||
@@ -88,7 +88,7 @@ describe('Regression transformation', () => {
|
||||
name: 'Linear regression',
|
||||
fields: [
|
||||
{ name: 'time', type: FieldType.time, values: [0, 1, 2, 3, 4, 5], config: {} },
|
||||
{ name: 'value predicted', type: FieldType.number, values: [1, 1, 1, 1, 1, 1], config: {} },
|
||||
{ name: 'value', type: FieldType.number, values: [1, 1, 1, 1, 1, 1], config: {} },
|
||||
],
|
||||
length: 6,
|
||||
}),
|
||||
|
||||
@@ -37,7 +37,7 @@ export const DEGREES = [
|
||||
|
||||
export const getRegressionTransformer: () => SynchronousDataTransformerInfo<RegressionTransformerOptions> = () => ({
|
||||
id: DataTransformerID.regression,
|
||||
name: t('transformers.regression.name.regression-analysis', 'Regression analysis'),
|
||||
name: t('transformers.regression.name.trendline', 'Trendline'),
|
||||
description: t(
|
||||
'transformers.regression.description.create-new-data-frame',
|
||||
'Create a new data frame containing values predicted by a statistical model.'
|
||||
@@ -129,7 +129,7 @@ export const getRegressionTransformer: () => SynchronousDataTransformerInfo<Regr
|
||||
fields: [
|
||||
{ name: xField.name, type: xField.type, values: predictionPoints, config: {} },
|
||||
{
|
||||
name: `${getFieldDisplayName(yField, predictFromFrame, frames)} predicted`,
|
||||
name: `${getFieldDisplayName(yField, predictFromFrame, frames)}`,
|
||||
type: yField.type,
|
||||
values: predictionPoints.map((x) => result.predict(x - normalizationSubtrahend)),
|
||||
config: {},
|
||||
|
||||
@@ -171,5 +171,6 @@ export const getRegressionTransformerRegistryItem: () => TransformerRegistryItem
|
||||
help: getTransformationContent(DataTransformerID.regression).helperDocs,
|
||||
imageDark: darkImage,
|
||||
imageLight: lightImage,
|
||||
tags: new Set([t('transformers.regression-transformer-editor.tags.regression-analysis', 'Regression analysis')]),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13443,7 +13443,7 @@
|
||||
"create-new-data-frame": "Create a new data frame containing values predicted by a statistical model."
|
||||
},
|
||||
"name": {
|
||||
"regression-analysis": "Regression analysis"
|
||||
"trendline": "Trendline"
|
||||
}
|
||||
},
|
||||
"regression-transformer-editor": {
|
||||
@@ -13465,6 +13465,9 @@
|
||||
}
|
||||
},
|
||||
"regression": "regression",
|
||||
"tags": {
|
||||
"regression-analysis": "Regression analysis"
|
||||
},
|
||||
"tooltip-number-of-xy-points-to-predict": "Number of X,Y points to predict"
|
||||
},
|
||||
"rename-by-regex-transformer": {
|
||||
|
||||
Reference in New Issue
Block a user