rmw_partial_dependencies: Function to calculate partial dependencies after training...

View source: R/rmw_partial_dependencies.R

rmw_partial_dependenciesR Documentation

Function to calculate partial dependencies after training with rmweather.

Description

rmw_plot_partial_dependencies is rather slow.

Usage

rmw_partial_dependencies(
  model,
  df,
  variable,
  training_only = TRUE,
  resolution = NULL,
  n_cores = NA,
  verbose = FALSE
)

Arguments

model

A ranger model object from rmw_train_model.

df

Input data frame after preparation with rmw_prepare_data.

variable

Vector of variables to calculate partial dependencies for.

training_only

Should only the training set be used for prediction? The default is TRUE.

resolution

The number of points that should be predicted for each independent variable. If left as NULL, a default sequence will be generated. See partial for details.

n_cores

Number of CPU cores to use for the model calculation. The default is system's total minus one.

verbose

Should the function give messages?

Value

Tibble.

Author(s)

Stuart K. Grange

Examples




# Load packages
library(dplyr)
# Ranger package needs to be loaded
library(ranger)

# Prepare example data
data_london_prepared <- data_london %>% 
  filter(variable == "no2") %>% 
  rmw_prepare_data()

# Calculate partial dependencies for wind speed
data_partial <- rmw_partial_dependencies(
  model = model_london, 
  df = data_london_prepared, 
  variable = "ws", 
  verbose = TRUE
)

# Calculate partial dependencies for all independent variables used in model
data_partial <- rmw_partial_dependencies(
  model = model_london, 
  df = data_london_prepared, 
  variable = NA, 
  verbose = TRUE
)




rmweather documentation built on Nov. 21, 2023, 5:06 p.m.