The function label_sequences() launches an interactive app in your default web-browser that allows you to (1) visualize observations and existing ground truth or other state sequences, (2) label time-points with states of the provided hsmm model, (3) delete any existing ground truth, and (4) validate state sequences provided with the observation so that they are included in the ground truth. The app lets you select the sequence if the argument X contains several sequences and lets you zoom on particular sections of the sequences. Another slider allows you to select specific time-points of the sequence for labeling them. Closing the app window will stop the app and returns the updated ground truth.

label_sequences(model, X, ground_truth = data.frame(), verbose = FALSE)

Arguments

model

a hsmm object: the hidden semi-Markov model defined to decode the observations

X

a data.frame of observations. In addition to the sequence ID (seq_id), time-point (t) and variable columns, state sequences that the user would like to validate or compare to the ground truth can be specified as additional columns. These columns names should be state_xyz where xyz is a string identifying the decoding. xyz cannot be ground_truth, any other string is accepted.

ground_truth

(optional) a data.frame providing the initial set of labeled time-points. If not provided, the ground truth is initialized to an empty data.frame.

verbose

a logical (default = FALSE). Should the function print additional information?

Value

a data.frame which combines the initial ground truth (if provided) and the newly labeled time-points.

Examples

my_model = simple_model Xsim = simulate_hsmm(model = my_model, n_state_transition = 20, seq_id = "test_seq") Xsim = dplyr::rename(Xsim, state_simulated_sequence = state) if (FALSE) { ground_truth = label_sequences(model = my_model, X = Xsim) if(nrow(ground_truth)>0) table(model$state_names[ground_truth$state]) }