【问题标题】:Rolling linear regression for use with groupby operation on a cuDF dataframe滚动线性回归,用于 cuDF 数据帧上的 groupby 操作
【发布时间】:2020-08-02 17:15:22
【问题描述】:

我想使用 cuML LinearRegression 计算 y_value 在 x_value 上的滚动斜率。

样本数据(cuDF 数据框):

| date       | x_value | y_value |
| ------     | ------  |  ----   |
| 2020-01-01 | 900     | 10      |
| 2020-01-01 | 905     | 15      |
| 2020-01-01 | 910     | 15      |
| 2020-01-01 | 915     | 15      |
| 2020-01-02 | 900     | 30      |
| 2020-01-02 | 905     | 40      |
| 2020-01-02 | 910     | 50      |
| ------     | ------  | ------  |

一个使用线性回归的简单函数:

def RollingOLS(x, y):
    lr = LinearRegression(fit_intercept = True, normalize = False, algorithm = 'svd')
    reg = lr.fit(x, y)
    
    return reg.coef_

我想做的事:

data.groupby('date').rolling(2).apply(RollingOLS, x=x_value, y=y_value)

但是,我收到一个错误:NotImplementedError: Handling UDF with null values is not yet supported。有没有办法克服这个错误?谢谢。

【问题讨论】:

    标签: numba numba-pro rapids cudf


    【解决方案1】:

    为了解决错误NotImplementedError: Handling UDF with null values is not yet supported,请将None/null 值重新分配给另一个值,或者从您的DataFrame 中删除具有None/null 值的样本。

    【讨论】:

    • 一旦您解决了上述错误,我认为您的代码将无法正常工作。请提供可重现的代码版本,以帮助进一步分析。
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 2018-07-26
    • 2017-05-21
    • 2021-08-21
    • 2017-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多