Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Predict probabilities on testing data
- predicted_probabilities <- predict(model2, newdata = test_data, type = "response")
- # Convert predicted probabilities to binary predictions (1 if P>0.5, else 0)
- predicted_classes <- ifelse(predicted_probabilities > 0.5, 1, 0)
- # Compute confusion matrix for model evaluation
- confusion_matrix <- table(Predicted = predicted_classes, Actual = test_data$upgraded)
- print(confusion_matrix)
- # Compute evaluation metrics
- accuracy <- sum(predicted_classes == test_data$upgraded) / length(predicted_classes)
- precision <- confusion_matrix[2,2] / sum(confusion_matrix[2,])
- recall <- confusion_matrix[2,2] / sum(confusion_matrix[,2])
- # Print evaluation metrics
- print(paste("Accuracy: ", accuracy))
- print(paste("Precision: ", precision))
- print(paste("Recall: ", recall))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement