![](/img/trans.png)
[英]XGBOOST-Multi class prediction. Prediction matrix is set of probabilities for classes. How to perform confusion matrix
[英]Testing Recommendation systems: How to specify how many items were given for the prediction. `calcPredictionAccuracy` function
我想測試我所創建的一個二進制的推薦系統recommenderlab
包。 當我運行calcPredictionAccuracy
函數時,出現以下錯誤:
.local(x,data,...)中的錯誤:您需要指定給出了多少項用於預測! 我進行了無數次搜索,但似乎找不到解決此問題的任何方法。 如果我嘗試添加給定的參數,錯誤將變為:
error.ubcf <-calcPredictionAccuracy(p.ubcf,getData(test_index,“ unknown”,給定= 3)).local(x,...)中的錯誤:未使用的參數(給定= 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”)).local(x,data,...)中的錯誤:您需要指定給出多少項用於預測!
我的問題是我的代碼中必須指出要預測多少項? 這個問題與我的數據是二進制數據有關嗎?
謝謝
羅伯特
對於topNList,必須指定要返回的項目數。 因此,您可以通過predict()函數調用添加它們:
# 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.