robyn_clusters: Clustering to Reduce Number of Models based on ROI and Errors

View source: R/clusters.R

robyn_clustersR Documentation

Clustering to Reduce Number of Models based on ROI and Errors

Description

robyn_clusters() uses output from robyn_run(), to reduce the number of models and create bootstrapped confidence interval and help the user pick up the best (lowest combined error) of the most different kinds (clusters) of models.

Usage

robyn_clusters(
  input,
  dep_var_type,
  cluster_by = "hyperparameters",
  all_media = NULL,
  k = "auto",
  wss_var = 0.06,
  max_clusters = 10,
  limit = 1,
  weights = rep(1, 3),
  dim_red = "PCA",
  quiet = FALSE,
  export = FALSE,
  seed = 123,
  ...
)

Arguments

input

robyn_export()'s output or pareto_aggregated.csv results.

dep_var_type

Character. For dep_var_type 'revenue', ROI is used for clustering. For conversion', CPA is used for clustering.

cluster_by

Character. Any of: "performance" or "hyperparameters".

all_media

Character vector. Default to InputCollect$all_media. Includes InputCollect$paid_media_spends and InputCollect$organic_vars.

k

Integer. Number of clusters

wss_var

Numeric. Used to pick automatic k value, when k is NULL based on WSS variance while considering limit clusters. Values between (0, 1). Default value could be 0.05 to consider convergence.

max_clusters

Integer. Maximum number of clusters.

limit

Integer. Top N results per cluster. If kept in "auto", will select k as the cluster in which the WSS variance was less than 5%.

weights

Vector, size 3. How much should each error weight? Order: nrmse, decomp.rssd, mape. The highest the value, the closer it will be scaled to origin. Each value will be normalized so they all sum 1.

dim_red

Character. Select dimensionality reduction technique. Pass any of: c("PCA", "tSNE", "all", "none").

quiet

Boolean. Keep quiet? If not, print messages.

export

Export plots into local files?

seed

Numeric. Seed for reproducibility

...

Additional parameters passed to lares::clusterKmeans().

Value

List. Clustering results as labeled data.frames and plots.

Author(s)

Bernardo Lares (bernardolares@meta.com)

Examples

## Not run: 
# Having InputCollect and OutputCollect results
cls <- robyn_clusters(
  input = OutputCollect,
  all_media = InputCollect$all_media,
  k = 3, limit = 2,
  weights = c(1, 1, 1.5)
)

## End(Not run)

Robyn documentation built on June 27, 2024, 9:06 a.m.