Skip to content
Snippets Groups Projects
Commit 2c46589c authored by Felix Ramnelöv's avatar Felix Ramnelöv
Browse files

Lab 2: Fixed error in assignment 2

parent e8f82697
No related branches found
No related tags found
No related merge requests found
......@@ -165,15 +165,11 @@ F1(test$y, y_hat4)
# ----5.----
loss_matrix = matrix(c(0, 1, 5, 0), ncol = 2)
fit5 <- tree(y ~ ., data = train)
pruned_tree5 = prune.tree(fit5,
loss = loss_matrix,
best = sum(fit5$frame$var == "<leaf>"))
probs5 <- predict(fit5, newdata = test, type = "vector")
y_hat5 = predict(pruned_tree5, newdata = test, type = "class")
y_hat5 <- ifelse(probs5[, "no"] / probs5[, "yes"] > 5, "no", "yes")
table(test$y, y_hat5)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment