make_pred_plot: Prediction Power Heatmap

View source: R/make_pred_plot.R

make_pred_plotR Documentation

Prediction Power Heatmap

Description

Creates a heatmap for visualizing prediction power from a prediction power matrix.

Usage

make_pred_plot(mat, title, low = "azure4", high = "white", text_size = 2.5)

Arguments

mat

matrix returned by prediction_power. Entries should contain expected conditional entropies EH(Z|X,Y).

title

character string giving the plot title.

low

color for low expected conditional entropy values. Default is "steelblue".

high

color for high expected conditional entropy values. Default is "white".

text_size

numeric value controlling the size of the cell labels. Default is 2.5.

Details

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.

Value

A ggplot object showing a heatmap of expected conditional entropy values. Darker cells indicate lower prediction uncertainty and therefore higher prediction power.

See Also

prediction_power, entropy_trivar

Examples

# 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")

netropy documentation built on April 24, 2026, 9:06 a.m.