我想使用 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 |
| ------ | ------ | ------ |
使用 LinearRegression 的简单函数:
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
。有什么办法可以克服这个错误吗?谢谢。
最佳答案
为了解决错误 NotImplementedError: Handling UDF with null values is not yet supported
请将 None/null
值重新分配给另一个值或删除具有 None/null
来自您的 DataFrame 的值。
关于numba - 用于 cuDF 数据帧上的 groupby 操作的滚动线性回归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63218943/