I have a model m and am trying to extract parameter arguments and put them in a dataframe. The arguments I'd like are in :
m[["fit"]][["fit"]][["spec"]][["args"]]
and are listed as:
$mtry
expr: ^7L
env: empty
$trees
expr: ^1225L
env: empty
$min_n
expr: ^26L
env: empty
$tree_depth
expr: ^5L
env: empty
$learn_rate
expr: ^0.2322614074394
env: empty
$loss_reduction
expr: ^0.61222263464654
env: empty
$sample_size
expr: ^0.813209898024797
env: empty
$stop_iter
expr: ^3L
env: empty
I've tried unlisting, tidy and other helpers which don't work - is there a way to get this information into a tibble or dataframe?
Thanks
Hi!
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
ok, I usually do this but my issue is with managing the results of a tidy model object (not the process of making the object). If I'm not able to upload the model object I need to figure out how to reprex the object creation.
Thanks for your response.
Hlynur
September 6, 2023, 4:59pm
4
Hi Michael,
I think you should be able to access them and put in a dataframe by mapping quo_get_expr
over it and then just bind_rows
:
library(tidyverse)
library(rlang)
m[["fit"]][["fit"]][["spec"]][["args"]] %>%
map(rlang::quo_get_expr) %>%
bind_rows(.id = "parameter_name")
But hard to verify without a reprex. If I'm incorrect regarding the above code, let me know and I could have a better look at it.
awesome, that works. Thank you for helping me out.
1 Like
system
Closed
September 13, 2023, 5:10pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.