成本敏感度量mlr_measures_classif.costs
需要一个'response'
预测类型。
msr("classif.costs")
#<MeasureClassifCosts:classif.costs>
#* Packages: -
#* Range: [-Inf, Inf]
#* Minimize: TRUE
#* Properties: requires_task
#* Predict type: response
predict_type
即使将学习者的设置为:此措施似乎也有效'prob'
:
# get a cost sensitive task
task = tsk("german_credit")
# cost matrix as given on the UCI page of the german credit data set
# https://archive.ics.uci.edu/ml/datasets/statlog+(german+credit+data)
costs = matrix(c(0, 5, 1, 0), nrow = 2)
dimnames(costs) = list(truth = task$class_names, predicted = task$class_names)
print(costs)
# mlr3 needs truth in columns, predictions in rows
costs = t(costs)
# create measure which calculates the absolute costs
m = msr("classif.costs", id = "german_credit_costs", costs = costs, normalize = FALSE)
# fit models and calculate costs
learner = lrn("classif.rpart", predict_type = "prob")
rr = resample(task, learner, rsmp("cv", folds = 3))
rr$aggregate(m)
#german_credit_costs
# 341
为什么它的工作predict_type
设置为'prob'
?这是一个错误还是该度量在内部将概率转换为类?我猜预测一个类别为正面或负面的阈值在内部设置为 0.5?可以改变这个阈值吗?