Description Usage Arguments Examples
View source: R/plot_magic_carpet.R
This plot visually compares how predictions change over a factor.
The ratio of two predictions proposed_pred/incumbent_pred
is calculated for each row. Two plots are produced which display
For each level of the feature we find what is the proportion of row with each ratio
For each value of the ratio what is the proportion of row with each value of the feature
The log2 is used to calculate the ratio as this is symmetrical
the values of log2(proposed_pred/incumbent_pred)
which are plotted are -ratio_max, -(n * ratio_step), -((n-1) * ratio_step), ..., -ratio_step, 0, ratio_step, ..., (n-1) * ratio_step, n * ratio_step, ratio_max
1 2 3 4 5 6 7 8 9 10 11 | plot_magic_carpet(
feature,
feature_name,
incumbent_pred,
proposed_pred,
weight = rep(1, length(feature)),
n_bins = 10,
ratio_max = 1,
ratio_step = 0.05,
position = "fill"
)
|
feature |
array[numeric/character/factor] - value of feature |
feature_name |
character - name of feature |
incumbent_pred |
array[numeric] - values of incumbent prediction |
proposed_pred |
array[numeric] - values of proposed prediction |
weight |
array[numeric] - weight of each row |
n_bins |
intergerish - number of buckets to split each (numeric) feature into |
ratio_max |
numeric - max ratio at which to cap the incumbent_pred/proposed_pred ratio |
ratio_step |
numeric - step size to divide ratio bins. |
position |
character - either |
1 2 3 4 5 6 7 8 9 10 11 12 13 | n=100
feature1 <- seq(-10, 10, length.out=n)
feature2 <- rep(c("a", "b", "c"), each=ceiling(n/3))[1:n]
incumbent_pred <- 100 + rnorm(n)
proposed_pred <- 100 + rnorm(n) + seq(-10, 10, length.out=n)
plot_magic_carpet(feature=feature1, feature_name="example feature",
incumbent_pred = incumbent_pred,
proposed_pred = proposed_pred)
plot_magic_carpet(feature=feature2, feature_name="example feature",
incumbent_pred = incumbent_pred,
proposed_pred = proposed_pred)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.