0
我需要基於Yelp數據庫製作推薦人,我已經過濾了商業評論和用戶,並創建了一個realRatingMatrix
,其中包含各個企業的用戶評分。即使矩陣將是巨大的,我只是先測試一個非常小的矩陣(mdat
矩陣)。R package'recommenderlab'預測函數輸出錯誤?
#learning matrix
learningM <- as(mdat[1:8,],"realRatingMatrix")
# matrix to predict user recommendations
testM <- as(mdat[9:10,],"realRatingMatrix")
#using the learning matrix to create a UBCF recommender
rec <- Recommender(learningM, method = "UBCF")
#function that should output 2 business recommendations to users of testM
pre <- predict(rec, testM, n=2)
相反,我收到這樣的輸出:
> as(pre,"list")
[[1]]
character(0)
[[2]]
character(0)
爲什麼會出現這樣的輸出? predict
函數計算錯誤的結果,從而提供錯誤的輸出或我的業務欄名稱是不同的文本類型,所以他不能正確輸出它?
編輯:mdat
矩陣按要求,抱歉沒有把它放在第一位。
> dput(mdat)
structure(c(1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 5, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 5, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 5), .Dim = c(10L, 10L), .Dimnames = list(
c("jqhP9mV2rYvmPdKvlOfp0g", "tqkkmL2NB19Sxeg1AaXnSA", "cNMJxBzmXA9N7krLvlrzlA",
"9v3uIUTitC043Y4Qs54K1g", "nLUwyI34R-cAHLnmEGeLIg", "6SUSTwhfSFva9nbIDmoN7Q",
"iCppbv3C7XvCyzIZnNQ7fg", "MUo7TLgR7sy1ob0MvxyPHQ", "GMVQyHMHNGplG3aof8jMcA",
"VNGevHJuTxcou-Nhm8Q5RQ"), c("iZYDZvXoIT648EZOnEP0pQ", "HQJjHA6BRcRD0vR5askdkQ",
"bul_5Ahk_QYLUAJ4Od27jg", "EOoj2h1Brzk1AhqScvIHDA", "roEQNfyPi3jRv3WFFr-f_g",
"ffp58kYSK7dJGs5ER-5txw", "pvlM--HZY1a8SqMXiwEz1A", "mta3FuoNzjjGWQr9TCHGhA",
"QeK3lOP-CTZS72YgeXiiqA", "57VozB9tq5SbNst9nO-jxA")))
錯誤在於沒有人可以在沒有數據的情況下回答問題。從dput(mdat)' –
@BondedDust矩陣添加後輸出。 – Vitz
大部分數據都是NA,訓練和測試集的dimname中沒有重疊。因此,訓練集中沒有任何東西可以用來在訓練和測試集的特徵之間進行類似的計算。 –