0

I am trying to create a decision tree algorithm for a multiclass classification. I decided to use the mlr3 package in order to have maximum options for parameter tuning. However I seem to have problems with creating the classification task. The data used for the task is in a dataframe with multiple variables, all numerical and one factor, which is "cluster", with four levels 1-4. This is also the target variable. This is the curent code:

task = as_task_classif(trainset, target = "cluster", id="clusters")
print(task)

When I run this code the output is:

Features:
NULL

I do not really understand why no features are created, hopefully someone can help me with this question.

Here is an example of the dataframe that I am using

Age <- c(58, 31, 58, 23, 58, 14)
Length <- c(185, 187, 180, 190, 184, 154)
Weight <- c(78, 86, 75, 69, 87, 46)
Skinfolds <- c(34, 49, 34, 26, 39, 21)
BMI <- c(17, 24, 23, 21, 26, 19)
cluster<- as.factor(c(3, 4, 3, 2, 1, 2))
trainset <- data.frame(Age, Length, Weight, Skinfolds, BMI, cluster)
DKampman
  • 1
  • 2
  • Hi @DKampman, welcome to SO! Could you please add a sample data frame for the example to be reproducible? – Omri374 Jul 29 '21 at 14:49
  • @Omri374 Thanks! I added an example of the data frame. I hope this helps. – DKampman Jul 29 '21 at 16:05
  • Hey @DKampman, when I rerun your code everything works just fine. Can you double check that you don't have any typos when you run your code? – damir Jul 29 '21 at 16:26
  • Thanks for checking. I decided to hard reset my RStudio and after rerunning the code, now it does work. There might have been too many packages loaded or conflicting information in the Global Environment, I'm not entirely sure why it didn't worked before. Thanks! – DKampman Jul 29 '21 at 16:45

1 Answers1

0

I had the same issue in RStudio (v 1.4.1717). In the R native GUI was everything OK.

The problem was in the mlr package, which was used shortly before. However, restarting and clearing of the workspace did not help for me. I had to close all the scripts where the mlr package was used and then clear workspace + restart R.

PWaldauf
  • 1
  • 1