Quickstart of mlr3 package
2022-08-13 本文已影响0人
灵活胖子的进步之路
As a 30-second introductory example, we will train a decision tree model on the first 120 rows of iris data set and make predictions on the final 30, measuring the accuracy of the trained model.
library("mlr3")
task = tsk("iris")
learner = lrn("classif.rpart")
# train a model of this learner for a subset of the task
learner$train(task, row_ids = 1:120)
# this is what the decision tree looks like
learner$model

predictions = learner$predict(task, row_ids = 121:150)
predictions

predictions$score(msr("classif.acc"))
predictions$confusion
predictions$truth
