diff --git a/lab2/assignment2.R b/lab2/assignment2.R index f9653925158cb2ec8afa7276c684eedfe9f115c4..0cd21f782752fdc403ea6cdcedfe14d36b612b27 100644 --- a/lab2/assignment2.R +++ b/lab2/assignment2.R @@ -102,6 +102,9 @@ optimal_tree <- prune.tree(fit2c, best = optimal_leaves) summary(optimal_tree) +plot(optimal_tree) +text(optimal_tree, pretty=0) + # ----4.---- TP <- function(x, x_pred) { @@ -237,25 +240,25 @@ legend( pch = c(16, 1) ) -# plot( -# logistic_recall, -# logistic_precision, -# type = "b", -# ylim = c(0, 1), -# xlim = c(0, 1), -# col = "red", -# main = "Precision depending on recall", -# xlab = "Recall", -# ylab = "Precision", -# pch = 16, -# ) -# points(tree_recall, -# tree_precision, -# col = "blue", -# type = "b") -# legend( -# "bottomleft", -# legend = c("Logistic regression model", "Optimal tree"), -# fill = c("red", "blue"), -# pch = c(16, 1) -# ) \ No newline at end of file +plot( + logistic_recall, + logistic_precision, + type = "b", + ylim = c(0, 1), + xlim = c(0, 1), + col = "red", + main = "Precision depending on recall", + xlab = "Recall", + ylab = "Precision", + pch = 16, +) +points(tree_recall, + tree_precision, + col = "blue", + type = "b") +legend( + "bottomleft", + legend = c("Logistic regression model", "Optimal tree"), + fill = c("red", "blue"), + pch = c(16, 1) +) \ No newline at end of file