View source: R/make_pred_plot.R
| make_pred_plot | R Documentation |
Creates a heatmap for visualizing prediction power from a prediction power matrix.
make_pred_plot(mat, title, low = "azure4", high = "white", text_size = 2.5)
mat |
matrix returned by |
title |
character string giving the plot title. |
low |
color for low expected conditional entropy values. Default is
|
high |
color for high expected conditional entropy values. Default is
|
text_size |
numeric value controlling the size of the cell labels. Default is 2.5. |
The plot visualizes expected conditional entropies
EH(Z|X,Y)
where Z is the target variable and X and Y are predictors. Diagonal entries correspond to prediction using a single predictor, EH(Z|X), while off-diagonal entries correspond to prediction using pairs of predictors, EH(Z|X,Y). Lower values indicate stronger predictive power.
A ggplot object showing a heatmap of expected conditional
entropy values. Darker cells indicate lower prediction uncertainty and
therefore higher prediction power.
prediction_power, entropy_trivar
# use internal data set
data(lawdata)
# extract node attributes
df_att <- lawdata[[4]]
# data editing:
# 1. discretize 'years' and 'age' into 3 categories
# 2. ensure values start at 0 where needed
att_var <- data.frame(
status = df_att$status - 1,
gender = df_att$gender,
office = df_att$office - 1,
years = ifelse(df_att$years <= 3, 0,
ifelse(df_att$years <= 13, 1, 2)),
age = ifelse(df_att$age <= 35, 0,
ifelse(df_att$age <= 45, 1, 2)),
practice = df_att$practice,
lawschool = df_att$lawschool - 1
)
# compute prediction power matrix for 'status'
pred_mat <- prediction_power("status", att_var)
# visualize prediction power
make_pred_plot(pred_mat, "Prediction Power for Status")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.