简体   繁体   中英

How to predict values from many R model in Power BI

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

Try adding version = 2 to saveRDS() to ensure the correct processing in the Power BI web-version (currently R3.4.4). Afterwards the import in PowerBI should work as explained in the tutorial via:

Get Data -> r-script -> readRDS("your model.rds")

Additionally it is also possible to import your whole workspace into PowerBI, see here , yet models still need to be imported seperatly via readRDS()

Sources:

orinigal tutorial

similar thread

PowerBI R version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM