bettinaputzi / cma_week3

Solving exercise 3 of the course "Computational Movement Analysis
0 stars 0 forks source link

Task 6 #2

Open KimboGilda opened 3 years ago

KimboGilda commented 3 years ago

https://github.com/bettinaputzi/cma_week3/blob/bc7e01ae52ab1cc037696058260809ab67a66f15/week3_rexercise.R#L97-L184

First of all nice try with the task. Below I am attaching a way to perform it in a cleaner way. The whole idea is based on using functional programming and more specifically some of functions of the purrr::map() family.

# first I am splitting the dataset based on each of the trajectories and
# then I am converting everything to a matrix with the help of purrr::map() function
pedestrians_matrix <- pedestrians %>%
  dplyr::select(E, N) %>%                   
  split(pedestrians$TrajID) %>%                
  map(as.matrix) # with map(), I am applying the as.matrix convertion to all of the created dataframes

as a second step, again using one of the functions of the purrr::map_* family -->imap_dfr, I am calculating three indices over all 5 pairs in one go.


pedest_measures <- imap_dfr(pedestrians_matrix, ~data_frame(                                             
  traj = .y,                                                  
  DTW = DTW(.x,pedestrians_matrix[[1]]),                                           
  EditDist = EditDist(.x,pedestrians_matrix[[1]]),                                                
  Frechet = Frechet(.x,pedestrians_matrix[[1]]),                                                   
  LCSS = LCSS(.x,[[1]],5,4,4)                                 
)) 
bettinaputzi commented 3 years ago

Hey Nikos, thanks for your help. I had issues interpreting the different outcomes. i tried it but i'm not sure if i got it right (see my comments in the code). would you mind giving me feedback on this too? in the solutions you only showed the right code without interpretation... thank you!

KimboGilda commented 3 years ago

Hey Nikos, thanks for your help. I had issues interpreting the different outcomes. i tried it but i'm not sure if i got it right (see my comments in the code). would you mind giving me feedback on this too? in the solutions you only showed the right code without interpretation... thank you!

Sure Bettina I can further explain. Have you pushed your changes/comments to your repo?