View source: R/counterfactual_model.R
run_counterfactual | R Documentation |
Chains detrending, training of a selected model, prediction and retrending together for ease of use. See documentation of individual functions for details.
run_counterfactual(
split_data,
params,
detrending_function = "none",
model_type = "rf",
alpha = 0.9,
log_transform = FALSE,
calc_shaps = FALSE
)
split_data |
List of two named dataframes called train and apply |
params |
A list of parameters that define the following:
|
detrending_function |
String which defines type of trend to remove.
Options are "linear","quadratic", "exponential", "spline", "none". See |
model_type |
String to decide which model to use. Current options random forest "rf", gradient boosted decision trees "lightgbm", "dynamic_regression" and feedforward neural network "fnn" |
alpha |
Confidence level of the prediction interval between 0 and 1. |
log_transform |
If TRUE, uses log transformation during detrending and
retrending. For details see |
calc_shaps |
Boolean value. If TRUE, calculate SHAP values for the
method used and format them so they can be visualised with |
Data frame of predictions, model and importance
data(mock_env_data)
split_data <- list(
train = mock_env_data[1:80, ],
apply = mock_env_data[81:100, ]
)
params <- load_params()
res <- run_counterfactual(split_data, params, detrending_function = "linear")
prediction <- res$retrended_predictions
random_forest_model <- res$model
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.