Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
patipati
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
v-chuncz-msft
Community Support
Community Support

@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.

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

 

unserialize(xraw): read error

Anonymous
Not applicable

Where you able to solve this issue?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.