Question: THIS IS THE SECOND TIME I POST THIS QUESTION PLUS CHEGGY DON'T REFUND ME FOR UNANSWERED/INCORRECT ANSWER. PLEASE ONLY ANSWER IF YOU KNOW AND UNDERSTAND
THIS IS THE SECOND TIME I POST THIS QUESTION PLUS CHEGGY DON'T REFUND ME FOR UNANSWERED/INCORRECT ANSWER.
PLEASE ONLY ANSWER IF YOU KNOW AND UNDERSTAND IT
R PROGRAMMING
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : factor CLOSEST_DEFENDER has new levels
I keep getting this error message when I run my code in R programming
here is part of the code that generate the error
```{r message=FALSE, warning=TRUE} # Training the data TIndex <- createDataPartition(cleaned_data_set$FGM, p=0.10, list = FALSE) # We will use the following for C5.0Tree and svmLinear3 training_data <- cleaned_data_set[TIndex,] # We test all the models with the 50% of data test_data <- cleaned_data_set[-TIndex,] # Cross validation params cross_validation_params <- trainControl(method = "cv", number = 5)
# Classification using C5.0Tree dec_tree_time<-system.time( dec_tree_model <- train(FGM ~ ., data = training_data, method = "C5.0Tree", trControl= cross_validation_params, na.action = na.omit ) )
# Predict dec_tree_predict <- predict(dec_tree_model, test_data, na.action = na.pass) # Create confusion matrix dec_tree_cm <-confusionMatrix(dec_tree_predict, test_data$FGM, positive = "1")
dec_tree_data <- c(dec_tree_cm$overall[["Accuracy"]], dec_tree_cm$byClass[["Sensitivity"]], dec_tree_cm$byClass[["Specificity"]], dec_tree_cm$byClass[["Precision"]], dec_tree_time[["elapsed"]], 0.5)
# SVM svm_time <- system.time( svm_model <- train(FGM ~ ., data = training_data, method = "svmLinear3", trControl= cross_validation_params, na.action = na.omit ) )
#Predict svM_predict <-predict(svm_model, test_data, na.action = na.pass) # Create confusion matrix svm_cm <-confusionMatrix(svM_predict, test_data$FGM, positive = "1")
svm_data <- c(svm_cm$overall[["Accuracy"]], svm_cm$byClass[["Sensitivity"]], svm_cm$byClass[["Specificity"]], svm_cm$byClass[["Precision"]], svm_time[["elapsed"]], 0.5)
result<-rbind(dec_tree_data, svm_data) colnames(result) <- c("Accuracy", "Sensitivity", "Specificity", "Precision", "Runtime", "Training Sample %") result ```
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
