Can nested data frame be used in machine learning?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can nested data frame be used in machine learning?

R help mailing list-2
Hello,

If we got a data frame like below, how to use "data" to predict type,
 if "data" is another data frame (called nested data frame):


by_subject
#> # A tibble: 1000 x 3
#>   subject            type       data            
#>   <fct>                <fct>      <list>          
#> 1 subject1      aa            <tibble [100 × 10]>
#> 2 subject2      bb           <tibble [100 × 10]>
#> 3 subject3      cc            <tibble [100 × 10]>
#> # … with 997 more rows


by_subject$data[[1]]
#> # A tibble: 100 x 10
#>    parts      weight    length    height
#>   <int>     <dbl>       <int>      <dbl>
#> 1    1         28.8           100          170
#> 2    2        30.3           105           169
#> 2    3       10.5            109           189
#> # … with 97 more rows

Sincerely yours,

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Can nested data frame be used in machine learning?

Bert Gunter-2
Your question is too vague to answer.

Many R functions have "predict" methods that can be used to make
predictions using a new object (e.g. a data frame) from a fitted object fit
on another data frame/object. See e.g. ?predict.lm for an exemplar. But
that's the closest I can come to guessing what you want.

I think you need to spend time with a tutorial or two on whatever
functions/methods you are using for "machine learning." You should not
expect us to do such homework for you.


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Oct 13, 2019 at 10:04 AM vod vos via R-help <[hidden email]>
wrote:

> Hello,
>
> If we got a data frame like below, how to use "data" to predict type,
>  if "data" is another data frame (called nested data frame):
>
>
> by_subject
> #> # A tibble: 1000 x 3
> #>   subject            type       data
> #>   <fct>                <fct>      <list>
> #> 1 subject1      aa            <tibble [100 × 10]>
> #> 2 subject2      bb           <tibble [100 × 10]>
> #> 3 subject3      cc            <tibble [100 × 10]>
> #> # … with 997 more rows
>
>
> by_subject$data[[1]]
> #> # A tibble: 100 x 10
> #>    parts      weight    length    height
> #>   <int>     <dbl>       <int>      <dbl>
> #> 1    1         28.8           100          170
> #> 2    2        30.3           105           169
> #> 2    3       10.5            109           189
> #> # … with 97 more rows
>
> Sincerely yours,
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Can nested data frame be used in machine learning?

Jeff Newmiller
In reply to this post by R help mailing list-2
predict doesn't know about nesting. You can either unnest or use lapply or purrr:map to create new nested data frames with predicted results, but it is up to you to decide where you want to put the results.

On October 13, 2019 10:03:36 AM PDT, vod vos via R-help <[hidden email]> wrote:

>Hello,
>
>If we got a data frame like below, how to use "data" to predict type,
> if "data" is another data frame (called nested data frame):
>
>
>by_subject
>#> # A tibble: 1000 x 3
>#>   subject            type       data            
>#>   <fct>                <fct>      <list>          
>#> 1 subject1      aa            <tibble [100 × 10]>
>#> 2 subject2      bb           <tibble [100 × 10]>
>#> 3 subject3      cc            <tibble [100 × 10]>
>#> # … with 997 more rows
>
>
>by_subject$data[[1]]
>#> # A tibble: 100 x 10
>#>    parts      weight    length    height
>#>   <int>     <dbl>       <int>      <dbl>
>#> 1    1         28.8           100          170
>#> 2    2        30.3           105           169
>#> 2    3       10.5            109           189
>#> # … with 97 more rows
>
>Sincerely yours,
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.