plotPopulation | R Documentation |
This function visualizes a population of models by plotting their feature importance or coefficients. It supports sorting of features by discriminance or importance, and allows for customization of colors and the number of columns in the layout.
plotPopulation(
pop,
X,
y,
sort.features = FALSE,
sort.ind = NULL,
col.sign = c("deepskyblue1", "firebrick1"),
ncol = 10,
slim = FALSE,
importance = FALSE
)
pop |
A population of models (either a list of models or a single model). |
X |
A data matrix or data frame where rows represent observations and columns represent features. |
y |
A vector of class labels (e.g., 1 and -1 for binary classification) corresponding to the rows in 'X'. |
sort.features |
Logical; if 'TRUE', the features will be sorted by their discriminance with respect to 'y'. Default is 'FALSE'. |
sort.ind |
A vector of indices for sorting the features. If 'NULL', the function will determine the order based on discriminance. Default is 'NULL'. |
col.sign |
A vector of two colors (default is 'c("deepskyblue1", "firebrick1")') used to represent positive and negative coefficients, respectively. |
ncol |
The number of columns to arrange the plots in (default is '10'). |
slim |
Logical; if 'TRUE', the plots will be simplified. Default is 'FALSE'. |
importance |
Logical; if 'TRUE', the feature importance will be plotted. Default is 'FALSE'. |
This function generates a series of plots for a population of models, displaying the feature coefficients or importances. If the population consists of multiple models, each model's coefficients or importances are plotted in a separate subplot. The function supports feature sorting based on their discriminance or importance, and customizes the layout of the plots.
If the population consists of a single model, a plot of the model's feature coefficients or importance is returned. If the population consists of multiple models, a grid of plots is displayed using 'grid.arrange'.
Edi Prifti (IRD)
# Example usage for a population of models
pop <- list(model1, model2, model3) # Assume these are pre-defined models
X <- data.frame(feature1 = rnorm(100), feature2 = rnorm(100))
y <- sample(c(1, -1), 100, replace = TRUE)
# Plot the population
plotPopulation(pop, X, y, sort.features = TRUE, ncol = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.