1

我的数据集 (be) 只是一个通用系列,我使用该系列的 2 个滞后值作为预测变量。当我通过 mlr3 运行 ranger 时,我收到一条错误消息,提示 pdata$se 中存在缺失值,不知道出了什么问题,数据集中没有缺失值。任何帮助表示赞赏。

library(mlr3verse)
library(ranger)
library(tidyverse)

be <- read_csv("index,series,lag1,lag2
1,7577039.736,3501685.67,3266643.3920000005
2,12670615.333999999,7577039.736,3501685.67
3,15547362.117999999,12670615.333999999,7577039.736
4,17862429.700000003,15547362.117999999,12670615.333999999
5,12456382.122,17862429.700000003,15547362.117999999
6,11776258.268,12456382.122,17862429.700000003
7,7415982.802,11776258.268,12456382.122
8,4909208.992,7415982.802,11776258.268
9,3153256.446,4909208.992,7415982.802
10,3627321.234,3153256.446,4909208.992
11,3598643.3920000005,3627321.234,3153256.446
12,3601685.67,3598643.3920000005,3627321.234
13,6851039.736,3601685.67,3598643.3920000005
14,12010615.333999999,6851039.736,3601685.67
15,14907362.117999999,12010615.333999999,6851039.736
16,17062069.700000003,14907362.117999999,12010615.333999999
17,13776351.902,17062069.700000003,14907362.117999999
18,11200258.268,13776351.902,17062069.700000003
19,7014952.802,11200258.268,13776351.902
20,5149328.592,7014952.802,11200258.268
21,3555456.446,5149328.592,7014952.802
22,3401281.694,3555456.446,5149328.592
23,3600643.512,3401281.694,3555456.446
24,3799885.67,3600643.512,3401281.694
25,6640039.915999999,3799885.67,3600643.512
26,13330615.414,6640039.915999999,3799885.67
27,15333362.797999999,13330615.414,6640039.915999999
28,17463529.756,15333362.797999999,13330615.414
29,13974352.982,17463529.756,15333362.797999999
30,11601538.787999999,13974352.982,17463529.756
31,7417952.998,11601538.787999999,13974352.982
32,5379327.002,7417952.998,11601538.787999999
33,3357456.446,5379327.002,7417952.998
34,3519881.694,3357456.446,5379327.002
35,3976643.3920000005,3519881.694,3357456.446
36,3827685.67,3976643.3920000005,3519881.694
37,7448839.736,3827685.67,3976643.3920000005
38,12072815.333999999,7448839.736,3827685.67
39,14607362.498,12072815.333999999,7448839.736
40,17278069.700000003,14607362.498,12072815.333999999
41,13984351.762,17278069.700000003,14607362.498
42,11640258.068,13984351.762,17278069.700000003
43,7374951.602,11640258.068,13984351.762
44,5149328.592,7374951.602,11640258.068
45,3757456.446,5149328.592,7374951.602
46,3773281.694,3757456.446,5149328.592
47,4057799.7260000003,3773281.694,3757456.446
48,3905802.05,4057799.7260000003,3773281.694
49,7600857.22,3905802.05,4057799.7260000003
50,12319199.668,7600857.22,3905802.05
51,14905472.284,12319199.668,7600857.22
52,17630683.714,14905472.284,12319199.668
53,14269747.042,17630683.714,14905472.284
54,11877814.702,14269747.042,17630683.714
55,7525461.166,11877814.702,14269747.042
56,5254417.278,7525461.166,11877814.702
57,3834139.578,5254417.278,7525461.166
58,3850287.79,3834139.578,5254417.278
59,4776868.952,3850287.79,3834139.578
60,6650859.738,4776868.952,3850287.79
61,8932155.812,6650859.738,4776868.952
62,13286680.239999998,8932155.812,6650859.738
63,15266373.356,13286680.239999998,8932155.812
64,14753582.824000001,15266373.356,13286680.239999998
65,11423115.616,14753582.824000001,15266373.356
66,9694168.222,11423115.616,14753582.824000001
67,12653617.627999999,9694168.222,11423115.616
68,3537417.068,12653617.627999999,9694168.222
69,2314654.84,3537417.068,12653617.627999999
70,1903689.762,2314654.84,3537417.068")

n_train <- 48
n_test <- 22

task <- TaskRegr$new(id = "regr_ranger",
                     backend = be,
                     target = "series")

learner <- lrn("regr.ranger", predict_type = "se")

set.seed(1502)
train <- learner$train(task, row_ids = 1:n_train)
test_preds <- learner$predict(task, row_ids = (n_train + 1):(n_train + n_test))
#> Warning in value[[3L]](cond): Calibration failed with error:
#> Error in approx(x = calib.x, y = calib.y, xout = vars): need at least two non-NA values to interpolate
#> Falling back to non-calibrated variance estimates.
#> Warning in sqrt(infjack$var.hat): NaNs produced
#> Error in check_prediction_data.PredictionDataRegr(pdata): Assertion on 'pdata$se' failed: Contains missing values (element 21).

reprex 包于 2021-05-14 创建 (v2.0.0 )

4

0 回答 0