Skip to content

Error in as.data.frame.default(x) : cannot coerce class ‘c("rand_forest", "model_spec")’ to a data.frame #297

Closed
@FrieseWoudloper

Description

@FrieseWoudloper

I installed parsnip and tried to fit a very simple random forest model. I ran this code:

library(parsnip)
library(titanic)

rand_forest() %>%
  set_mode("classification") %>%
  set_engine("randomForest") %>%
  set_args(trees = 1000, importance = TRUE) %>%
  fit(factor(Survived) ~ factor(Sex) + factor(Embarked), data = titanic_train)

It returned an error:

Error in as.data.frame.default(x) : 
  cannot coerce class ‘c("rand_forest", "model_spec")’ to a data.frame

It took me quite some time to figure out the solution was easy: install.package('randomForest')

It would be nice to get an error message that clearly states the problem: the randomForest package isn't installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions