Reputation: 21
I would like to evaluate my model with the function of the package Recommenderlab
scheme <- evaluationScheme(UserByProductRRM, method = "cross-validation", k = 10, given =-1 , goodRating = 4)
but I don't understand why I have this error
Error in sample.int(length(x), size, replace, prob) : invalid 'size' argument
Upvotes: 1
Views: 6349
Reputation: 149
The reason for this error seems to be that the dimensions of the sample fraction you want to extract from the data set cannot be calculated. That is, the value of the "size" parameter you specified cannot be calculated. Therefore, I suggest you try to see the "size" parameter from the console. The "evaluationScheme" function refers to the sample function. Sample function cannot calculate "size". An example of this is the following.
library(tidytext)
library(tidyverse)
library(dplyr)
data("iris")
df_iris<-as.data.frame(iris)
train<-sample(1:nrow(df_iris),0.60*nrow(df))
nrow(df)
Console:
> train<-sample(1:nrow(df_iris),0.60*nrow(df))
Error in sample.int(length(x), size, replace, prob) :
invalid 'size' argument
> nrow(df)
NULL
There is nothing called "df" that can be calculated and passed to the "size" parameter. The calculation could not be done and the "size" parameter was missing. This caused an error.
Upvotes: 0