knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
rsticklebackA machine learning pipeline for detecting fine-scale behavioral events in bio-logging data.
You can install the development version of rstickleback from GitHub with:
# install.packages("devtools") devtools::install_github("FlukeAndFeather/rstickleback")
stickleback takes a time series classification approach to detect behavioral events in longitudinal bio-logging data.The included sensor data contains the depth, pitch, roll, and speed of six blue whales at 10 Hz, and the event data contains the times of lunge-feeding behaviors.
library(rstickleback) # `load_lunges()` returns a list of sensors and events, so we use the multiple # assignment operator (%<-%) to destruct the list into separate `lunge_sensors` # and `lunge_events` objects. c(lunge_sensors, lunge_events) %<-% load_lunges() # Again we use %<-%, to divide the sensors and events into test and train sets test_deployids <- deployments(lunge_sensors)[1:3] c(sensors_test, sensors_train) %<-% divide(lunge_sensors, test_deployids) c(events_test, events_train) %<-% divide(lunge_events, test_deployids)
sb_plot_data() produces an interactive figure for exploring bio-logger data.
deployid <- deployments(lunge_sensors)[1] sb_plot_data(deployid, lunge_sensors, lunge_events)

Initialize a Stickleback model using Supervised Time Series Forests and a 5 s window.
tsc <- compose_tsc(module = "interval_based", algorithm = "SupervisedTimeSeriesForest", params = list(n_estimators = 2L, random_state = 4321L), columns = columns(lunge_sensors)) sb <- Stickleback(tsc, win_size = 50, tol = 5, nth = 10, n_folds = 4, seed = 1234)
Fit the Stickleback object to the training data.
sb_fit(sb, sensors_train, events_train)
Make predictions on the test data and assess prediction outcomes.
predictions <- sb_predict(sb, sensors_test) outcomes <- sb_assess(sb, predictions, events_test) outcomes
sb_plot_predictions() produces an interactive figure for exploring model predictions.
deployid <- deployments(sensors_test)[1] sb_plot_predictions(deployid, sensors_test, predictions, outcomes)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.