Linear regression gradient(线性回归梯度(Linear regression gradient))¶
Supported in: Batch
Returns the slope of the linear regression line for non-null pairs in a group. Returns null if there are insufficient non-null pairs or if the variance of the independent variable is zero.
Expression categories: Aggregate
Declared arguments¶
- Left: The independent variable.
Expression\ - Right: The dependent variable.
Expression\
Output type: Double
Examples¶
Example 1: Base case¶
Argument values:
- Left:
left - Right:
right
Given input table:
| left | right |
|---|---|
| 1 | 5 |
| 2 | 4 |
| 3 | 3 |
| 4 | 2 |
| 5 | 1 |
Outputs: -1.0
Example 2: Base case¶
Argument values:
- Left:
left - Right:
right
Given input table:
| left | right |
|---|---|
| 9.0 | 2.0 |
| 27.0 | 2.0 |
| 34.0 | 2.0 |
| 14.0 | 2.0 |
| 51.0 | 2.0 |
Outputs: 0.0
Example 3: Base case¶
Argument values:
- Left:
left - Right:
right
Given input table:
| left | right |
|---|---|
| 9.0 | 8.0 |
| 9.0 | 2.0 |
| 9.0 | 1.0 |
| 9.0 | 3.0 |
| 9.0 | 2.0 |
Outputs: null
Example 4: Null case¶
Argument values:
- Left:
left - Right:
right
Given input table:
| left | right |
|---|---|
| 1.0 | 2.0 |
| null | null |
| null | 1.0 |
| 1.0 | null |
| 2.0 | 1.0 |
Outputs: -1.0
中文翻译¶
线性回归梯度(Linear regression gradient)¶
支持环境:批处理(Batch)
返回组内非空值对的线性回归线斜率。如果非空值对不足或自变量的方差为零,则返回空值。
表达式类别: 聚合(Aggregate)
声明参数¶
- 左侧(Left): 自变量。
表达式\<数值类型>(Expression\) - 右侧(Right): 因变量。
表达式\<数值类型>(Expression\)
输出类型: 双精度浮点数(Double)
示例¶
示例1:基础情况¶
参数值:
- 左侧(Left):
left - 右侧(Right):
right
给定输入表:
| left | right |
|---|---|
| 1 | 5 |
| 2 | 4 |
| 3 | 3 |
| 4 | 2 |
| 5 | 1 |
输出结果: -1.0
示例2:基础情况¶
参数值:
- 左侧(Left):
left - 右侧(Right):
right
给定输入表:
| left | right |
|---|---|
| 9.0 | 2.0 |
| 27.0 | 2.0 |
| 34.0 | 2.0 |
| 14.0 | 2.0 |
| 51.0 | 2.0 |
输出结果: 0.0
示例3:基础情况¶
参数值:
- 左侧(Left):
left - 右侧(Right):
right
给定输入表:
| left | right |
|---|---|
| 9.0 | 8.0 |
| 9.0 | 2.0 |
| 9.0 | 1.0 |
| 9.0 | 3.0 |
| 9.0 | 2.0 |
输出结果: null
示例4:空值情况¶
参数值:
- 左侧(Left):
left - 右侧(Right):
right
给定输入表:
| left | right |
|---|---|
| 1.0 | 2.0 |
| null | null |
| null | 1.0 |
| 1.0 | null |
| 2.0 | 1.0 |
输出结果: -1.0