【发布时间】:2020-04-10 00:07:06
【问题描述】:
问题
在函数中的数据框中添加行以进行精度测量。
R 中的努力
函数 compute_accuracy.func() 返回精度准确度测量值。 IF 循环调用 compute_accuracy.func() 并向 data.frame 添加新行。
向数据框添加新行,不起作用
需要为每个 for...循环添加新行,使用阈值并计算精度。我是在 for...loop 中动态地将新行添加到 R data.frame 的新手。
compute_accuracy.func <- function(t_threshold) {
tryCatch({
x <- accuracy.meas(full$y, loans_predict$fit, threshold=t_threshold)
return(x$precision)
},
error = function(e) return(e)
)
}
df_accuracies <- data.frame(n=0, threshold=0, precision=0)
compute_for_values = seq(0.1,0.9,by=0.1)
for(i in compute_for_values){
threshold = i
precision <- compute_accuracy.func(i)
df_accuracies[nrow(df_accuracies) + 1,] <- rbind(threshold, precision)
}
【问题讨论】: