View source: R/rmw_train_model.R
rmw_train_model | R Documentation |
Function to train a random forest model to predict (usually) pollutant concentrations using meteorological and time variables.
rmw_train_model(
df,
variables,
n_trees = 300,
mtry = NULL,
min_node_size = 5,
keep_inbag = TRUE,
n_cores = NA,
verbose = FALSE
)
df |
Input tibble after preparation with |
variables |
Independent/explanatory variables used to predict
|
n_trees |
Number of trees to grow to make up the forest. |
mtry |
Number of variables to possibly split at in each node. Default is the (rounded down) square root of the number variables. |
min_node_size |
Minimal node size. |
keep_inbag |
Should in-bag data be kept in the ranger model
object? This needs to be |
n_cores |
Number of CPU cores to use for the model calculation. Default is system's total minus one. |
verbose |
Should the function give messages? |
A ranger model object, a named list.
Stuart K. Grange
rmw_prepare_data
, rmw_normalise
# Load package
library(dplyr)
# Keep things reproducible
set.seed(123)
# Prepare example data
data_london_prepared <- data_london %>%
filter(variable == "no2") %>%
rmw_prepare_data()
# Calculate a model using common meteorological and time variables
model <- rmw_train_model(
data_london_prepared,
variables = c(
"ws", "wd", "air_temp", "rh", "date_unix", "day_julian", "weekday", "hour"
),
n_trees = 300
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.