| plot_loss_heatmap | R Documentation |
Draws an efficient raster heatmap for selected observations, with a narrow total-contribution strip. For a local Q-SHAP result, the default display is 'local_rsq': observation-level contributions to the global R-squared decomposition, with legend values formatted as percentages. The underlying values remain unchanged. The diverging fill scale is centered at zero.
plot_loss_heatmap(
loss,
global_importance = NULL,
feature_names = NULL,
quantity = NULL,
samples = NULL,
n_show = 40,
title = NULL,
xtitle = "Feature",
ytitle = "Observations",
legend_title = NULL,
low_color = "#2166AC",
mid_color = "white",
high_color = "#B2182B",
rotation = 45,
save_name = NULL
)
loss |
A numeric contribution matrix with observations in rows and features in columns, or a 'qshap_rsq'/'qshap_result' object produced with 'local = TRUE'. |
global_importance |
Optional numeric vector used to order features from most to least globally important. For a 'qshap_rsq' object, '$rsq' is used automatically. For a matrix, the default is '-colSums(loss)' when 'quantity = "loss"' and 'colSums(loss)' when 'quantity = "local_rsq"'. |
feature_names |
Optional feature labels. Defaults to 'colnames(loss)'. |
quantity |
Quantity to display when 'loss' is a Q-SHAP result: '"local_rsq"' for local contributions on the R-squared scale or '"loss"' for raw contributions to the change in squared loss. The default uses 'local_rsq' when available and otherwise falls back to 'loss'. For a matrix, this argument controls labels and the default feature-ordering rule; the matrix itself is displayed unchanged. |
samples |
Optional observation indices or row names/IDs to display. If 'NULL', informative observations are selected automatically from both extremes of the row sums. |
n_show |
Total number of observations selected automatically when 'samples = NULL'. Approximately half are taken from each extreme. |
title |
Optional plot title. For 'local_rsq', the default is "Observation-level contributions to the global R^2 decomposition". |
xtitle |
X-axis title. |
ytitle |
Y-axis title. |
legend_title |
Optional fill legend title. Defaults to "Local R^2 contribution" for 'local_rsq'. |
low_color |
Color for negative contributions. |
mid_color |
Color for zero. |
high_color |
Color for positive contributions. |
rotation |
Rotation angle for feature labels. |
save_name |
Optional output path without the '.pdf' extension. |
A ggplot2 object, invisibly.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.