0

After running the following R code:

#' load libraries
library(parallelMap)
library(mlr)

#' *** Define the task
task = makeClassifTask(id = "classif_prem", 
                       data = data, 
                       target = "Result")

#' *** Define the learner
lrn = makeLearner(id = "learn_prem", cl = "classif.xgboost")

#' train model
mod = train(learner = lrn, task = task)

After running str(data) I get:

> str(data)
Classes ‘tbl_df’ and 'data.frame':  210 obs. of  3 variables:
 $ Result  : Factor w/ 3 levels "Draw","Loss",..: 1 3 1 1 1 2 2 2 1 1 ...
 $ RankDiff: int  11 3 11 5 -14 11 -2 -4 5 -8 ...
 $ DiffDiff: num  1.5 -1 1.5 -1 -1 0 0 -1.5 0 -1.5 ...

The task summary gives:

Supervised task: classif_prem
Type: classif
Target: Result
Observations: 210
Features:
numerics  factors  ordered 
       2        0        0 
Missings: FALSE
Has weights: FALSE
Has blocking: FALSE
Classes: 3
Draw Loss  Win 
  61   64   85 
Positive class: NA
Warning message:
drop ignored 

I then get the error:

Error in xgb.setinfo(dmat, names(p), p[[1]]) : 
The length of labels must equal to the number of rows in the input data
In addition: Warning message:
drop ignored 

Any help for me to avoid this error would be appreciated. Thanks.

sagrules
  • 31
  • 1
  • 7
  • Could you share the data you're using? It looks like it should work. – Lars Kotthoff Jan 30 '16 at 02:55
  • 2
    it looks like you are passing a tbl_df instead of a data.frame as the data element in the task. they don't have exactly the same properties, i would start by casting the tbl_df back to a data.frame. but as lars says without the data i can't tell you exactly what is going on. – Zach Feb 01 '16 at 19:59
  • Thank you very much. The additional tbl_df class was messing with mlr and xgboost. I made it only a data.frame and it worked. – sagrules Feb 03 '16 at 19:29

1 Answers1

1

Thank you very much. The additional tbl_df class was messing with mlr and xgboost. I made it only a data.frame and it worked.

sagrules
  • 31
  • 1
  • 7