0

我想可视化这个博客上显示的分类器结果。但是,在这些示例中,它们仅使用二维数据。但我想可视化更高维的数据。一个基本过程是将 PCA 应用于特征空间并仅绘制前两个 PCA 组件。

修改 rr resample_result R6 类会很棒。但我不知道如何访问这些数据。

任何帮助将非常感激。提前致谢。

library("mlr3verse")
library("mlr3viz")

learners = list(
  # k-nearest neighbours classifier
  lrn("classif.kknn", id = "kkn", predict_type = "prob", k = 3),
  
  # linear svm
  lrn("classif.svm", id = "lin. svm", predict_type = "prob", kernel = "linear")
)

design = benchmark_grid(
  tasks = tsk("iris"),
  learners = learners,
  resamplings = rsmp("holdout")
)

bmr = benchmark(design, store_models = TRUE)

perf = bmr$aggregate(msr("classif.acc"))[, c("task_id", "learner_id", "classif.acc")]
perf


n = bmr$n_resample_results
plots = vector("list", n)
for (i in seq_len(n)) {
  rr = bmr$resample_result(i)
  
  rr.pred <- as.data.table(as.data.table(rr)$prediction[[1]])
  ## doing pca ... with something like %>>% po("pca")
  plots[[i]] = autoplot(rr, type = "prediction")
  ## Error: Plot learner prediction only works for tasks with two features for classification! 
}
4

0 回答 0