2017-07-25 2 views
0

私はrecommenderlabパッケージで作成したバイナリ推薦システムをテストしようとしています。 calcPredictionAccuracy関数を実行すると、次のエラーが表示されます。テストの推奨システム:予測のために与えられたアイテムの数を指定する方法。 `calcPredictionAccuracy`関数

.local(x、data、...)のエラー: 予測に与えられたアイテムの数を指定する必要があります。 私は数多くの検索を行っており、この問題の解決策を見つけることができないようです。私は与えられた引数のエラーの変更を追加しようとした場合:ここで

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

私のコードで簡単に見ている:

私のデータセットは、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 for comparison 
Rec.ibcf <- Recommender(getData(test_index, "train"), "IBCF") 
# making predictions on the test data set 
p.ubcf <- predict(Rec.ubcf, getData(test_index, "known"), type="topNList") 
# making predictions on the test data set 
p.ibcf <- predict(Rec.ibcf, getData(test_index, "known"), type="topNList") 
# obtaining the error metrics for both approaches and comparing them 

##error occurs with the following two 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") 

これです次のエラーが発生します。

error.ubcf<-calcPredictionAccuracy(p.ubcf, getData(test_index, "unknown")) Error in .local(x, data, ...) : You need to specify how many items were given for the prediction!

私のコードでは、いくつの項目が指定されなければなりませんか予測のために与えられる?この問題は私のデータがバイナリであるという事実に関連していますか?

おかげ

ロバート

答えて

0

はtopNListのために、あなたが戻って欲しいアイテムの数を指定する必要があります。だから、あなたが予測()関数呼び出しでこれらを追加します。

# making predictions on the test data set 
p.ubcf <- predict(Rec.ubcf, getData(test_index, "known"), type="topNList", n=10) 
# making predictions on the test data set 
p.ibcf <- predict(Rec.ibcf, getData(test_index, "known"), type="topNList", n=10) 

のnを変化させることにより、あなたはどのように影響を与えるあなたのTP/FP/TN/FN精度の対策だけでなく、高精度/リコールを見ることができます。これらの値の計算方法は、このページの最後にあります。 https://github.com/mhahsler/recommenderlab/blob/master/R/calcPredictionAccuracy.R

+0

ありがとうございます。それが問題を解決した – phillipsr

関連する問題