estimate_sleep: Estimate Sleep from Wrist-Worn Accelerometry

View source: R/classify.R

sl_python_modules_installedR Documentation

Estimate Sleep from Wrist-Worn Accelerometry

Description

Estimate Sleep from Wrist-Worn Accelerometry

Usage

sl_python_modules_installed(component = c("models", "features"))

estimate_sleep(data, epoch = 30L, model_dir, cores = 1L)

Arguments

component

Python dependency set to check. The default, "models", checks all modules needed for sleep classification; "features" checks only the feature-extraction modules.

data

A data.frame with columns of timestamp, x, y, z

epoch

Time in seconds for the time interval estimate

model_dir

path to the folder with models from \Sexpr[results=rd]{tools:::Rd_expr_doi("10.5281/zenodo.3752645")}

cores

Number of workers to use for model prediction. Any non-zero integer accepted by Python joblib is allowed; -1 uses all available workers. Defaults to one worker for CRAN compatibility.

Value

A tibble of times and classification of category.

Examples


  if (sl_python_modules_installed("models")) {
    models = sl_example_model()
    if (!is.null(models) && requireNamespace("readr", quietly = TRUE)) {
      file = system.file("extdata", "example_data.csv.gz", package = "sleeper")
      data = readr::read_csv(file, n_max = 3600L)
      # Two minutes is sufficient to demonstrate the workflow and avoids
      # applying the forest to the full 12-hour example recording.
      try({estimate_sleep(data, model_dir = dirname(models$binary[1]))})
    }
  }


sleeper documentation built on Sept. 17, 2026, 5:08 p.m.