मैंने आर कैरेट के साथ एक पेड़ मॉडल को प्रशिक्षित किया है। अब मैं एक भ्रम मैट्रिक्स उत्पन्न करने के लिए कोशिश कर रहा हूँ और निम्न त्रुटि प्राप्त हो रही है: जब भ्रम की स्थिति पैदा करने मैट्रिक्सConfusionMatrix में त्रुटि डेटा और संदर्भ कारकों में स्तरों की समान संख्या होनी चाहिए R CARET
Error in confusionMatrix.default(predictionsTree, testdata$catgeory) : the data and reference factors must have the same number of levels
prob <- 0.5 #Specify class split
singleSplit <- createDataPartition(modellingData2$category, p=prob,
times=1, list=FALSE)
cvControl <- trainControl(method="repeatedcv", number=10, repeats=5)
traindata <- modellingData2[singleSplit,]
testdata <- modellingData2[-singleSplit,]
treeFit <- train(traindata$category~., data=traindata,
trControl=cvControl, method="rpart", tuneLength=10)
predictionsTree <- predict(treeFit, testdata)
confusionMatrix(predictionsTree, testdata$catgeory)
त्रुटि तब होती है। दोनों वस्तुओं पर स्तर समान हैं। मैं समझ नहीं सकता कि समस्या क्या है। उनकी संरचना और स्तर नीचे दिए गए हैं। वे वही होना चाहिए। किसी भी मदद की सराहना की जाएगी क्योंकि यह मुझे क्रैक कर रहा है !!
> str(predictionsTree)
Factor w/ 30 levels "16-Merchant Service Charge",..: 28 22 22 22 22 6 6 6 6 6 ...
> str(testdata$category)
Factor w/ 30 levels "16-Merchant Service Charge",..: 30 30 7 7 7 7 7 30 7 7 ...
> levels(predictionsTree)
[1] "16-Merchant Service Charge" "17-Unpaid Cheque Fee" "18-Gov. Stamp Duty" "Misc" "26-Standard Transfer Charge"
[6] "29-Bank Giro Credit" "3-Cheques Debit" "32-Standing Order - Debit" "33-Inter Branch Payment" "34-International"
[11] "35-Point of Sale" "39-Direct Debits Received" "4-Notified Bank Fees" "40-Cash Lodged" "42-International Receipts"
[16] "46-Direct Debits Paid" "56-Credit Card Receipts" "57-Inter Branch" "58-Unpaid Items" "59-Inter Company Transfers"
[21] "6-Notified Interest Credited" "61-Domestic" "64-Charge Refund" "66-Inter Company Transfers" "67-Suppliers"
[26] "68-Payroll" "69-Domestic" "73-Credit Card Payments" "82-CHAPS Fee" "Uncategorised"
> levels(testdata$category)
[1] "16-Merchant Service Charge" "17-Unpaid Cheque Fee" "18-Gov. Stamp Duty" "Misc" "26-Standard Transfer Charge"
[6] "29-Bank Giro Credit" "3-Cheques Debit" "32-Standing Order - Debit" "33-Inter Branch Payment" "34-International"
[11] "35-Point of Sale" "39-Direct Debits Received" "4-Notified Bank Fees" "40-Cash Lodged" "42-International Receipts"
[16] "46-Direct Debits Paid" "56-Credit Card Receipts" "57-Inter Branch" "58-Unpaid Items" "59-Inter Company Transfers"
[21] "6-Notified Interest Credited" "61-Domestic" "64-Charge Refund" "66-Inter Company Transfers" "67-Suppliers"
[26] "68-Payroll" "69-Domestic" "73-Credit Card Payments" "82-CHAPS Fee" "Uncategorised"
आपकी त्रुटि में, 'श्रेणी'' वर्तनी 'वर्तनी है। यदि समस्या से संबंधित नहीं है, तो समान (स्तर (पूर्वानुमान (ट्री), स्तर (testdata $ श्रेणी)) का आउटपुट क्या है? – fxi
हाय के लिए धन्यवाद, मैंने मूर्खतापूर्ण वर्तनी गलती की है .... दोह !!! मैंने समान फ़ंक्शन चलाया और इसे आउटपुट किया [1] TRUE ......... अब जब मैं भ्रम चलाता हूं तो मुझे निम्न त्रुटि मिल रही है मैट्रिक्स फ़ंक्शन ..... तालिका में त्रुटि (डेटा, संदर्भ, dnn = डीएनएन, ...): सभी तर्कों में एक ही लंबाई – user2987739
एक और गलत वर्तनी 'catgeory' की जांच करनी चाहिए,' लंबाई (testdata $ श्रेणी) 'और 'लंबाई (भविष्यवाणियां ट्री' की जांच करें, दोनों वैक्टरों का सारांश भी देखें। यदि आप बस एक साधारण भ्रम मैट्रिक्स चाहते हैं: 'तालिका (भविष्यवाणियां, testdata $ श्रेणी) ' – fxi