snowflake.snowpark.functions.regr_intercept¶
- snowflake.snowpark.functions.regr_intercept(y: Union[Column, str], x: Union[Column, str]) Column [source]¶
Returns the intercept of the univariate linear regression line for non-null pairs in a group. It is computed for non-null pairs using the following formula: AVG(y)-REGR_SLOPE(y,x)*AVG(x), where x is the independent variable and y is the dependent variable.
Example:
>>> df = session.create_dataframe([[10, 11], [20, 22], [30, 35]], schema=["v", "v2"]) >>> df.groupBy().agg(regr_intercept(df["v"], df["v2"]).alias("regr_intercept")).collect() [Row(REGR_INTERCEPT=1.1547344110854496)]