on 01-03-2015 3:20 PM
I am trying to run 'recommenderlab' library of R with SAP PA custom component.
I have tested it in many ways - it is a new library, so I thought that maybe it is not keen on those, that haven't been included in the default installation. I found a place, where SAP PA configures stuff what to include in the installation of R and reinstalled but to no avail.
Then I tried another library - seriation - that that had not been included, but this worked, even without being included in SAP PA installation script (I had seriation previously in my local R installation, though). Whereas the recommenderlab library, once I give the first command: q<-as(mydata, "realRatingMatrix”): which coerces the original SAP data to a realRatingMatrix form with the help of the package, just gives an error.
The SAP PA error message, once I add the row is a general one:
Error, could not find function MyMain.
In the SAP PA logs, I get a more detailed error message:
Error during processing response.: boolean is not a function
The script works fine in my R installation and thus I don't know what to do next?
The script:
mymain <-function(mydata, howmany)
{
howmany<-as.numeric(howmany)
library(recommenderlab)
q<-as(mydata, "realRatingMatrix”)
r<- Recommender(q, method = "POPULAR")
recom <- predict(r, q, n = howmany)
l<-as(recom,"list")
res<-cbind(rep(seq_along(l), times=sapply(l, length)), unlist(l))
output <- as.data.frame(res)
return(list(out=output))
}
log file location
C:\Users\JaanU_000\AppData\Local\Temp\sapvi\logs
installation script location
C:\Program Files\SAP Predictive Analysis\Desktop\plugins\com.sap.pa.runtime.config_1.20.0.201410080051-36\resources\R64
The csv data that I am passing to the custom component as mydata
userid | productid | rating |
1 | 1 | 2.5 |
1 | 2 | 3.5 |
1 | 3 | 3 |
1 | 4 | 3.5 |
1 | 5 | 2.5 |
1 | 6 | 3 |
2 | 1 | 3 |
2 | 2 | 3.5 |
2 | 3 | 1.5 |
2 | 4 | 5 |
2 | 6 | 3 |
2 | 5 | 3.5 |
3 | 1 | 2.5 |
3 | 2 | 3 |
3 | 4 | 3.5 |
3 | 6 | 4 |
4 | 2 | 3.5 |
4 | 3 | 3 |
4 | 6 | 4.5 |
4 | 4 | 4 |
4 | 5 | 2.5 |
5 | 1 | 3 |
5 | 2 | 4 |
5 | 3 | 2 |
5 | 4 | 3 |
5 | 6 | 3 |
5 | 5 | 2 |
6 | 1 | 3 |
6 | 2 | 4 |
6 | 6 | 3 |
6 | 4 | 5 |
6 | 5 | 3.5 |
7 | 2 | 4.5 |
7 | 5 | 1 |
7 | 4 | 4 |
Interesting topic
I have worked directly in R for a while before the introduction of SAP PA and one thing you need to be aware of is that the R packages you install quite frequently refer to other R packages to work.
If you install an R package in R and then subsequently refer to the installed package using the library function you will immediatly see if you need to install more R packages as an error will occur if that is the case.
So always test the if the R package references are also installed before proceeding - and as also mentioned before the R packages needs to be in the correct folder location
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jaan,
I have been struggling with exactly the same problem for a while. A very likely reason for your error is this:
When you are using PA with R components, PA looks only at specific locations for the liberalisers. If you happen to install the given library (i.e. "recomandable") through R-studio, it is likely that has install the library somewhere else. Good news is that you can specify the exact location where you want your library to be installed. Follow these steps:
From the PA check the installation path of your R: Go to File> Installation and configuration of R , then click on configuration. Take a note of the R path. Then from R studio (or other IDE) install the package as
install.packages("recomandable", lib="C:/Users/Public/R-3.1.0/library") replace the path with your own R installation Path. After the installation you should check the subfolder in your R path and you should see a folder named as "recomandable"
This should hopefully solve your problem. Let me know otherwise.
Rouzbeh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Rouzbeh and Andreas for help!
Rouzbeh, thanks to your pointer, I have done everything with library locations, to the best of my knowledge.
Andreas sent me the working component, with my own code and I compared the XML files (the working component and my non-working one) next to each other.
The difference is the following:
Somewhere in the XML file of the working component, there is a place:
<Attributes masterSet="NONE" size="2" >
in my not-working components it is set to
<Attributes masterSet="ALL" size="2" >
When I edit my component to be similar to yours, in that respect, it works.
Why would that make the difference and how to get SAP PA to do this automatically?
Hello Jaan,
The message "cannot find function..." usually means SAP PA did not recognize the R function. In most cases this relates to a typo in the code. If you are sure the R function is valid, please try replacing all the double quotes to a single quote
So for instance turn this
q<-as(mydata, "realRatingMatrix”)
into
q<-as(mydata, 'realRatingMatrix')
If you still ge tthe same error message, can you please try to simpflify the function even further to test at which point it starts working.
Greetings
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Andreas!
Thank you for coming to my help!
I don't think this is it. I have tried it with single or double quotes. Also, this is as simple of a form as I can get it down to. It takes the basic input data for recommender systems (user-product-rating) and does the first operation - coercing, which turn column input data into a recommender systems readable form (realRatingsMatrix). I cannot run any commands before this. Also, I have tried another custom package - seriation. This also starts with coercing (to a matrix form) and this works. I really spent more than 24 hours on trying to get it to work, but have run out of ideas.
All the necessary data is in my first letter, if you could give it a try?
With many thanks,
Jaan
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.