viralmodel {viralmodels}R Documentation

Select best model

Description

Returns performance metrics for a selected model

Usage

viralmodel(
  traindata,
  semilla,
  target,
  viralvars,
  logbase,
  pliegues,
  repeticiones,
  rejilla,
  modelo
)

Arguments

traindata

A data frame

semilla

A numeric value

target

A character value

viralvars

Vector of variable names related to viral data.

logbase

The base for logarithmic transformations.

pliegues

A numeric value

repeticiones

A numeric value

rejilla

A numeric value

modelo

A character value

Value

A table with a single model hyperparameters

Examples


library(tidyverse)
library(baguette)
library(kernlab)
library(kknn)
library(ranger)
library(rules)
library(glmnet)
# Define the function to impute values in the undetectable range
set.seed(123)
impute_undetectable <- function(column) {
ifelse(column <= 40,
      rexp(sum(column <= 40), rate = 1/13) + 1,
            column)
            }
# Apply the function to all vl columns using purrr's map_dfc
library(viraldomain)
data("viral", package = "viraldomain")
viral_imputed <- viral |>
mutate(across(starts_with("vl"), ~impute_undetectable(.x)))
traindata <- viral_imputed
semilla <- 1501
target <- "cd_2022"
viralvars <- c("vl_2019", "vl_2021", "vl_2022")
logbase <- 10
pliegues <- 2
repeticiones <- 1
rejilla <- 1
modelo <- "simple_rf"
set.seed(123)
viralmodel(traindata, semilla, target, viralvars, logbase, pliegues, repeticiones, rejilla, modelo)


[Package viralmodels version 1.3.1 Index]