Closed fatimamb closed 6 years ago
Where does BC_bind
come from? I'm getting the error object 'BC_bind' not found
BC_bind is the dataset
Please provide an example with the error that I can reproduce on my laptop. Thanks
https://www.dropbox.com/s/fsz07fkme5nlz4s/WPDC.xlsx?dl=0
here is the dataset
I'm used specific columns so I saved them on BC_bind as shown in the code.
Top_6featurs <- wpdc[,c(33,11,10,32,29,12)] #column number of top 6 featur
BC_bind <- data.frame(cbind(Top_6featurs , wpdc$outcome))
Oops! I though you had a qestion regarding mltools. This type of question would be better posted on StackOverflow. Nonetheless, try working with this.
rfe_nB_folds<-createFolds(BC_bind$outcome, k=10) #create folds
rfe_nB_fun <- lapply (rfe_nB_folds, function(x){
rfe_nB_traing_folds<-BC_bind[-x,]
rfe_nB_test_folds<-BC_bind[x,]
#build the model
rfe_nB_model<-naiveBayes(outcome ~ ., data = rfe_nB_traing_folds)
#test the model
rfe_nB_predict<-predict(rfe_nB_model, rfe_nB_test_folds, type="raw")
predClasses <- c("N", "R")[rfe_nB_predict[, "N"] < 0.5 + 1]
#ROC
CR<-roc.curve(rfe_nB_test_folds[["outcome"]] == "N", rfe_nB_predict[, "N"])
print(CR)
rfe_nB_table<-table(rfe_nB_test_folds[["outcome"]], predClasses)
rfe_nB_confusionMatrix<-confusionMatrix(rfe_nB_table)
return (rfe_nB_confusionMatrix$table)
})
I will try it, thank you for your time
I'm used 10 cross-validations with naive Bayes as shown in my code. I need to plot ROC, because of that I added (type=raw) to predict function to be as probabilities but I had an error with table function and ROC plot. How can deal with this error?
The error of ROC:
The error of table:
My code:
best regards, fatima