2

I have many models, like:

iris2 <- data.frame(zzz= sample(c(0, 1),size =  length(iris$Sepal.Length), replace = TRUE), iris)
for (i in unique(iris$Species)) {
  saveRDS(glm(zzz ~ Sepal.Length+Sepal.Width+Petal.Length+Petal.Width, data =  iris2[iris2$Species == i,]),
      file = paste0("model_", i))
}

I need to put these models inside power bi, for to run the predict function of R in power bi, But power bi doesn't accept list.

I was unsuccessful with the solution: https://towardsdatascience.com/how-to-predict-values-from-a-custom-r-model-in-power-bi-3364f83b0015

4

1 回答 1

0

尝试将version = 2添加到 saveRDS() 以确保在 Power BI Web 版本(当前为 R3.4.4)中正确处理。之后,PowerBI 中的导入应该按照教程中的说明通过以下方式进行:

获取数据 -> r-script -> readRDS("your model.rds")

此外,还可以将整个工作区导入 PowerBI,请参见此处,但仍需要通过 readRDS() 单独导入模型

资料来源:

原始教程

类似的线程

PowerBI R 版本

于 2020-04-06T09:30:30.007 回答