1

i have an lm model that i built in r. i've saved the model as an rds file to load it into a power bi r visual. power bi desktop r visuals read rds files but it seems that power bi service r visuals do not read rds files

=> 1) am i right or is there a way to load rds files into power bi service r visuals?

as a solution, i've saved the model as a json (pfa) file using the aurelius package. i then load the json file as part of the data model. once the pfa is loaded in power bi, i use the pfa_engine function to get predictions from the model. however, the pfa_engine function is part of the rPython package which is not available in the power bi service.

=> 2) is there a way to get predictions without using the pfa_engine? the read_pfa function can only return a list object (not a model object). many thanks

elfersi
  • 121
  • 2
  • 13
  • Is there a particular reason why you don't want to put your R script directly in an R visulaization? Or use R in the Power Query Editor? – vestland Aug 22 '18 at 08:50
  • 1
    i don't want to train the model again every time i run the visual (it'd take a very long time). that is why i don't put the r script in the visual. the visual loads the model to predict according to user input from the dashboard. that is why i can't pre-load the model in power query: it needs to be calculated "on the fly". saving the model as an rds file and then loading in the visual in pbi desktop worked. it is only when i published the workbook in the service that if failed: it can't load the file – elfersi Aug 22 '18 at 16:30
  • so my options are: -> provide a path to the rds file in the visual within pbi service -> load the model as flat file in power query: e.g. txt, json... any clue? – elfersi Aug 22 '18 at 16:34
  • I'm sorry to say that I don't know at the time being. But this is an interesting issue so I'll see if I can find the time to test these things myself soon. – vestland Aug 22 '18 at 20:26
  • i did it using dput instead of rds thanks to @vhcandido' s answer [here](https://stackoverflow.com/questions/51992464/convert-string-back-into-object-in-r) i saved the model as a text file then loaded it in pbi since it was part of the data model, i could load it into the r visual and re-build it thanks! – elfersi Aug 27 '18 at 22:09

0 Answers0