r - Testing Recommendation systems: How to specify how many items were given for the prediction. `calcPredictionAccuracy` function -


i trying test binary recommendation systems created recommenderlab package. when run calcpredictionaccuracy function following error:

error in .local(x, data, ...) : need specify how many items given prediction! have performed numerous searches , can't seem find solution issue. if try add given argument error changes to:

error.ubcf<-calcpredictionaccuracy(p.ubcf, getdata(test_index, "unknown", given=3)) error in .local(x, ...) : unused argument (given = 3)

here quick @ code:

my data set binary.watch.ratings

affinity.matrix <- as(binary.watch.ratings,"binaryratingmatrix") test_index <- evaluationscheme(affinity.matrix[1:1000], method="split",  train=0.9, given=1)   # creation of recommender model based on ubcf rec.ubcf <- recommender(getdata(test_index, "train"), "ubcf") # creation of recommender model based on ibcf comparison rec.ibcf <- recommender(getdata(test_index, "train"), "ibcf") # making predictions on test data set p.ubcf <- predict(rec.ubcf, getdata(test_index, "known"), type="topnlist") # making predictions on test data set p.ibcf <- predict(rec.ibcf, getdata(test_index, "known"), type="topnlist") # obtaining error metrics both approaches , comparing them  ##error occurs following 2 lines error.ubcf<-calcpredictionaccuracy(p.ubcf, getdata(test_index, "unknown")) error.ibcf<-calcpredictionaccuracy(p.ibcf, getdata(test_index, "unknown"))  error <- rbind(error.ubcf,error.ibcf) rownames(error) <- c("ubcf","ibcf") 

this produces following error:

error.ubcf<-calcpredictionaccuracy(p.ubcf, getdata(test_index, "unknown")) error in .local(x, data, ...) : need specify how many items given prediction!

my question point in code must specify how many items given prediction? issue related fact data binary?

thanks

robert

for topnlist, must specify number of items want back. add these predict() function call:

# making predictions on test data set p.ubcf <- predict(rec.ubcf, getdata(test_index, "known"), type="topnlist", n=10) # making predictions on test data set p.ibcf <- predict(rec.ibcf, getdata(test_index, "known"), type="topnlist", n=10) 

by varying n, able see how impacts tp/fp/tn/fn accuracy measures, precision/recall. calculation methodology these values @ bottom of page: https://github.com/mhahsler/recommenderlab/blob/master/r/calcpredictionaccuracy.r


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -