stats_noob
stats_noob

Reputation: 5907

R Error: unused argument (measures = list("f1", FALSE, etc)

I am trying to use the "mlr" library in R and the "c50" algorithm on the iris dataset (using the F1 score as the metric) :

library(mlr)
library(C50)
data(iris)

zooTask <- makeClassifTask(data = iris, target = "Species")
forest <- makeLearner("classif.C50")

forestParamSpace <- makeParamSet(
makeIntegerParam("minCases", lower = 1, upper = 100))


randSearch <- makeTuneControlRandom(maxit = 100)


cvForTuning <- makeResampleDesc("CV", iters = 5,  measures = f1)


tunedForestPars <- tuneParams(forest, task = zooTask,
resampling = cvForTuning,
par.set = forestParamSpace,
control = randSearch)



tunedForestPars

But this results in the following error:

Error in makeResampleDescCV(iters = 5, measures = list(id = "f1", minimize = FALSE,  : 
  unused argument (measures = list("f1", FALSE, c("classif", "req.pred", "req.truth"), function (task, model, pred, feats, extra.args) 
{
    measureF1(pred$data$truth, pred$data$response, pred$task.desc$positive)
}, list(), 1, 0, "F1 measure", "Defined as: 2 * tp/ (sum(truth == positive) + sum(response == positive))", list("test.mean", "Test mean", function (task, perf.test, perf.train, measure, group, pred) 
mean(perf.test), "req.test")))
> 

Can someone please show me how to fix this?

Thanks

Upvotes: 3

Views: 185

Answers (1)

Kra.P
Kra.P

Reputation: 15123

You would rather add measures argument in tuneParams. Also, because iris data is multi-class data, f1 is not available(as code says), see Implemented Performance Measures.

cvForTuning <- makeResampleDesc("CV", iters = 5)


tunedForestPars <- tuneParams(forest, task = zooTask,
                              resampling = cvForTuning,
                              par.set = forestParamSpace,
                              control = randSearch, 
                              measures = acc)

Upvotes: 5

Related Questions