0

I found the Cost-Sensitive OVO scheme with simple voting prediction (https://mlr-org.github.io/mlr-tutorial/devel/html/cost_sensitive_classif/index.html) but, is there a simple way to just follow a OVO scheme with all basic learners included in the MLR package without the cost matrix and weights?

thank you!!

edited after @Lars answer:

rm(list=ls(all=TRUE))
library(mlr)

df = iris
cost = matrix(runif(150 * 3, 0, 2000), 150) * (1 - diag(3))[df$Species,] + runif(150, 0, 10)
colnames(cost) = levels(iris$Species)
rownames(cost) = rownames(iris)
df$Species = NULL

costsens.task = makeCostSensTask(id = "iris", data = df, cost = cost)
costsens.task

lrn = makeLearner("classif.rotationForest")
lrn = makeCostSensWeightedPairsWrapper(lrn)
lrn

mod = train(lrn, costsens.task)
mod

getLearnerModel(mod)

pred = predict(mod, task = costsens.task)
pred

performance(pred, measures = list(meancosts, mcp), task = costsens.task)
  • You would need to chance the implementation. It's not clear to me why you would want to do this though. – Lars Kotthoff Sep 01 '17 at 17:19
  • On the one hand because I want to use ML algorithms that do not need to deal with weigths, for example a SVM (please check https://mlr-org.github.io/mlr-tutorial/devel/html/integrated_learners/index.html#classification-79 in order to find te lower number of algorithms that are able to deal with weigths). On the other hand, because I do not want to assign a cost matrix a priori. – cafernandezlo Sep 01 '17 at 23:55
  • Then you don't need to change anything -- learners that can't handle weights won't use them, and if nothing uses weights it doesn't matter what cost matrix you give. – Lars Kotthoff Sep 02 '17 at 00:04
  • I edited my question with a non-runnable code because the classifier (classif.rotationForest) does not support weights. The package always check if the classifier support weights and also if the classifier is for costsens tasks or not. How do you run this code without having to change anything? – cafernandezlo Sep 05 '17 at 23:59
  • Ah, right, you can't actually turn off those checks without modifying the code -- in this particular case it really doesn't make sense without the weights. As far as I understand what you're looking for exactly isn't implemented in mlr. – Lars Kotthoff Sep 06 '17 at 01:47
  • As one of the contributors of the package, what's the shorcut? ;) downloading the source code and turning off the checks? probably more problems arise, right? What I really want is to check is if a OVO+classif.naiveBayes improves a Multiclass naiveBayes for example. There are several different papers published on this regard. Of course, using all the power of this particular package, which in my humble opinion, is one of the best I've ever tested for machine learning research. – cafernandezlo Sep 06 '17 at 05:15
  • The easiest way to do this is to add the "weights" property to the learners you want to use. No guarantees that this will work as intended though. – Lars Kotthoff Sep 06 '17 at 15:00

0 Answers0