cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Importing Rds R model to Power BI - gam model

Hi,

 

 

I'm trying to pass parameters of Gam model using this method.

 

https://towardsdatascience.com/how-to-predict-values-from-a-custom-r-model-in-power-bi-3364f83b0015

 

Unfortunettaly I am gettign read error on unserialize function

 

from_byte_string = function(x) {
xcharvec = strsplit(x, " ")[[1]]
xhex = as.hexmode(xcharvec)
xraw = as.raw(xhex)
unserialize(xraw)

 

}

#project_folder <- "Z:/Datasets/NSA/EBITDA_adimensional/"
#finalfit <- readRDS(paste0(project_folder, "mtcars-model.rds"))

finalfit.str <- as.character( dataset[dataset$model_id == 1, "model_str"] )
finalfit <- from_byte_string(finalfit.str)

v <- c( wt=dataset$weight, qsec=dataset$qsec, am=as.factor(dataset$am) )

pred <- round( predict(finalfit, newdata = as.data.frame(t(v))), digits = 2 )

plot.new()
text(0.5, 0.5,
#labels = as.character(dataset$weight)
labels = as.character(pred[[1]])
,cex = 3.5
)
 
On IDE script is runnig properly.
 
Is there anyone who had tried it yet ? Can it be problem with library in Power BI ?
 
 
3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Importing Rds R model to Power BI - gam model

@patipati 

 

That works for me. Try the latest version of Power BI Desktop and take a good look at Create Power BI visuals with R.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Frequent Visitor

Re: Importing Rds R model to Power BI - gam model

I have March version, and R 3.5.3 and I'm still getting error with unserialize function:

 

unserialize(xraw): read error

Highlighted
Regular Visitor

Re: Importing Rds R model to Power BI - gam model

Where you able to solve this issue?

Helpful resources

Announcements
Super Users of the Quarter - Q2 2020

Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors