Skip to content

data inputs and outputs is not robust against character column, and fails with Error in torch_tensor_cpp(data, dtype, device, requires_grad, pin_memory) : R type not handled #124

@cregouby

Description

@cregouby

Current situation

any predictor being of type character() makes tabnet_* fails with the following error

Error in torch_tensor_cpp(data, dtype, device, requires_grad, pin_memory) : 
  R type not handled

Expected situation

character columns shall be turned into factors with a warning to the end-user about the number of levels discovered

Workaround

use a character to factor transformation upfront using tabnet_* functions

library(dplyr)
#> 
library(tabnet)
data("billboard", package = "tidyr")
billboard_fct <- billboard %>% mutate_if(is.character, as.factor)
model <- tabnet_fit(wk1 ~ ., data = billboard_fct)

Created on 2023-06-25 with reprex v2.0.2

ReprEx

library(tabnet)
data("billboard", package = "tidyr")

model <- tabnet_fit(wk1 ~ ., data = billboard)
#> Error in torch_tensor_cpp(data, dtype, device, requires_grad, pin_memory): R type not handled

Created on 2023-06-25 with reprex v2.0.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions