gpt4 book ai didi

r - if(ncol.matrix < rep) { : argument is of length zero 中的错误

转载 作者:行者123 更新时间:2023-12-03 13:40:51 25 4
gpt4 key购买 nike

需要帮助了解触发“ncol.matrix < rep”错误的原因。

我浏览了神经网络的源代码 https://rdrr.io/cran/neuralnet/src/R/neuralnet.r ,还调整了我的神经网络函数的参数,但我似乎无法阻止这个错误的发生。我不确定是否已经发布了这样的问题,但我找不到任何解决方案,因此,如果有人以前看过这样的问题,您能否将我链接到解决方案。

我还标准化了“WicketPerInnings”的目标列

Wnn <- neuralnet(
WicketFormula,
WTrain,
algorithm = "rprop+",
hidden = c(4,2),
stepmax = 1e+03,
threshold = 0.2,
rep = 40,
lifesign = 'full',
learningrate = 0.01,
startweights = NULL,
err.fct = "sse",
linear.output = TRUE
)

WicketFormula <-
"WicketPerInnings~ world_cup_matches+No_of_Matches + No_of_Innings_bowled+No_of_Balls_bowled + No_of_Runs_given+No_of_Wickets + Bowling_Ave + Economy_rate+Bowling_Strike_Rate + Span"

str(WTrain) 给出
 $ Country             : chr  "Sri Lanka" "Bangladesh" "South Africa" "India" ...
$ world_cup_matches : num 2 1 0 0 9 0 0 0 0 6 ...
$ No_of_Matches : num 102 2 7 16 77 10 24 5 10 136 ...
$ No_of_Innings_batted: num 84 2 4 5 72 8 22 3 8 113 ...
$ No_of_Not_Out : num 7 1 3 1 3 2 2 1 2 23 ...
$ Runs_Scored : num 1624 5 32 6 991 ...
$ Highest_Score : num 95 0 0 0 50 17 0 0 20 100 ...
$ Batting_Average : num 21.1 5 32 1.5 14.4 ...
$ No_of_Balls_Faced : num 2254 5 25 19 1461 ...
$ Batting_Strike_Rate : num 72 100 128 31.6 67.8 ...
$ No_of_Innings_bowled: num 10 2 7 16 75 9 12 5 10 117 ...
$ No_of_Balls_bowled : num 264 78 378 686 3385 ...
$ No_of_Runs_given : num 225 66 323 609 2865 ...
$ No_of_Wickets : num 2 1 7 24 67 5 6 8 13 69 ...
$ Bowling_Ave : num 112.5 66 46.1 25.4 42.8 ...
$ Economy_rate : num 5.11 5.07 5.12 5.32 5.07 4.99 3.76 4.17 2.8 4.79 ...
$ Bowling_Strike_Rate : num 132 78 54 28.5 50.5 88 53.3 26.2 40.3 54.1 ...
$ Span : num 11 0 0 4 8 7 7 5 4 12 ...
$ RunPerInnings : num 19.3 2.5 8 1.2 13.8 ...
$ WicketPerInnings : num 0.0374 0.1337 0.2941 0.4545 0.2599 ...````

summary(WTrain) gives
```` Country world_cup_matches No_of_Matches No_of_Innings_batted No_of_Not_Out Runs_Scored Highest_Score Batting_Average No_of_Balls_Faced
Length:756 Min. : 0.000 Min. : 1.00 Min. : 1.00 Min. : 0.000 Min. : 1.0 Min. : 0.00 Min. : 0.000 Min. : 1
Class :character 1st Qu.: 0.000 1st Qu.: 9.00 1st Qu.: 5.00 1st Qu.: 1.000 1st Qu.: 27.0 1st Qu.: 0.00 1st Qu.: 7.185 1st Qu.: 47
Mode :character Median : 0.000 Median : 26.00 Median : 15.50 Median : 4.000 Median : 120.0 Median : 11.00 Median :13.860 Median : 182
Mean : 5.152 Mean : 54.51 Mean : 40.45 Mean : 8.757 Mean : 899.3 Mean : 30.32 Mean :16.519 Mean : 1184
3rd Qu.: 7.000 3rd Qu.: 68.25 3rd Qu.: 44.25 3rd Qu.:12.000 3rd Qu.: 623.2 3rd Qu.: 50.00 3rd Qu.:24.000 3rd Qu.: 858
Max. :46.000 Max. :463.00 Max. :452.00 Max. :80.000 Max. :18426.0 Max. :219.00 Max. :95.000 Max. :21367
Batting_Strike_Rate No_of_Innings_bowled No_of_Balls_bowled No_of_Runs_given No_of_Wickets Bowling_Ave Economy_rate Bowling_Strike_Rate
Min. : 6.25 Min. : 1.00 Min. : 2 Min. : 1.0 Min. : 1.0 Min. : 1.00 Min. : 1.500 Min. : 2.00
1st Qu.: 54.37 1st Qu.: 6.75 1st Qu.: 232 1st Qu.: 186.8 1st Qu.: 5.0 1st Qu.: 27.82 1st Qu.: 4.327 1st Qu.: 34.95
Median : 69.17 Median : 17.00 Median : 674 Median : 546.5 Median : 15.0 Median : 34.41 Median : 4.865 Median : 42.95
Mean : 69.01 Mean : 37.65 Mean : 1697 Mean : 1312.4 Mean : 41.9 Mean : 39.24 Mean : 4.901 Mean : 48.15
3rd Qu.: 81.36 3rd Qu.: 48.00 3rd Qu.: 2081 3rd Qu.: 1656.2 3rd Qu.: 48.5 3rd Qu.: 43.94 3rd Qu.: 5.350 3rd Qu.: 53.92
Max. :328.57 Max. :365.00 Max. :18433 Max. :12066.0 Max. :523.0 Max. :201.00 Max. :11.140 Max. :222.00
Span RunPerInnings WicketPerInnings
Min. : 0.000 Min. : 0.250 Min. :0.0000
1st Qu.: 2.000 1st Qu.: 4.419 1st Qu.:0.1872
Median : 5.000 Median : 9.426 Median :0.2941
Mean : 5.668 Mean :12.630 Mean :0.2990
3rd Qu.: 9.000 3rd Qu.:19.177 3rd Qu.:0.3904
Max. :23.000 Max. :49.220 Max. :1.0000 ````

after running the code as it is, i encounter the error "Error in if (ncol.matrix < rep) { : argument is of length zero" and cannot proceed with prediction or anything else.

最佳答案

它也让我把头发拉出来。

我发现这个 issue 已经被合并到 master:https://github.com/bips-hb/neuralnet/pull/21 .

但它似乎还没有进入 CRAN。

所以我通过github安装了这个库

devtools::install_github("bips-hb/neuralnet")

它停止给出这个错误。要安装它,您可能需要安装 R tools在你的机器上。

关于r - if(ncol.matrix < rep) { : argument is of length zero 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56254321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com