Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

machine_learn ignores ordered factors #1296

Open
ecorreig opened this issue Feb 3, 2021 · 0 comments
Open

machine_learn ignores ordered factors #1296

ecorreig opened this issue Feb 3, 2021 · 0 comments

Comments

@ecorreig
Copy link

ecorreig commented Feb 3, 2021

The function machine_learn outputs models with wrong reference levels for factors. This code

library(dplyr)
library(healthcareai)

sino <- c("No", "Sí")
df <- tibble(
  x = sample(sino, 100, replace = T),
  y = sample(sino, 100, replace = T),
  z = sample(sino, 100, replace = T),
  a = 1:100
) %>%
  mutate(
    across(c(x, y), function(x) factor(x, ordered = T)),
    z = as.factor(z)
    )
mod <- machine_learn(df, outcome = z, models = "rf")

get_variable_importance(mod) %>%
  plot()

gives me:

image

sessionInfo():

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Catalan_Spain.1252 LC_CTYPE=Catalan_Spain.1252 LC_MONETARY=Catalan_Spain.1252
[4] LC_NUMERIC=C LC_TIME=Catalan_Spain.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] forcats_0.5.0 caret_6.0-86 lattice_0.20-41 ggplot2_3.3.2 cvAUC_1.1.0
[6] data.table_1.13.0 ROCR_1.0-11 healthcareai_2.5.0 compareGroups_4.4.5 missForest_1.4
[11] itertools_0.1-3 iterators_1.0.12 foreach_1.5.0 randomForest_4.6-14 dplyr_1.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant