plotNetwork | R Documentation |
Returns a plot of nodes and edges. Plots are created with the ggraph and igraph packages.
plotNetwork(
decision_ensemble,
path_length = Inf,
layout = "stress",
colour_edge_low = "#E69F00",
colour_edge_mid = "grey87",
colour_edge_high = "#0072B2",
colour_node_low = "#E69F00",
colour_node_mid = "grey87",
colour_node_high = "#0072B2",
text_size = 4,
hide_isolated_nodes = TRUE,
seed = 0
)
decision_ensemble |
stable decision ensemble: list with edges, nodes, etc. |
path_length |
maximal number of edges between 2 nodes, default = Inf. |
layout |
network layout, default is 'stress' (see ggraph package) |
colour_edge_low |
colour for the negative interaction influence values (i.e., edges; default: yellowish) |
colour_edge_mid |
colour for the null interaction influence values (i.e., edges; default: light grey) |
colour_edge_high |
colour for the positive interaction influence values (i.e., edges; default: blue) |
colour_node_low |
colour for the negative feature influence values (i.e., nodes; default: yellowish) |
colour_node_mid |
colour for the null feature influence values (i.e., nodes; default: light grey) |
colour_node_high |
colour for the positive feature influence values (i.e., nodes; default: blue) |
text_size |
size of node labels. |
hide_isolated_nodes |
logical, default = TRUE (= nodes without any edge are not shown). |
seed |
the seed to use for generating the network. |
a ggraph object
library(randomForest)
library(caret)
# import data and fit model
data(iris)
mod <- randomForest(Species ~ ., data = iris)
# Fit a decision ensemble to predict the species setosa (vs versicolor and
# virginica): no regularization (no decision pruning, discretization,
# bootstrapping, or decision filtering)
endo_setosa <- model2DE(model = mod, model_type = "rf", data = iris[, -5]
, target = iris$Species, classPos = "setosa"
, filter = FALSE, discretize = FALSE, prune = FALSE)
# Only decision pruning (default = TRUE) and discretization (default in 2
# categories, we want 3 categories so we change K); no bootstrapping or
# decision filtering.
endo_setosa <- model2DE(model = mod, model_type = "rf", data = iris[, -5]
, target = iris$Species, classPos = "setosa"
, filter = FALSE, discretize = TRUE, K = 3)
# idem but run it in parallel on 2 threads
endo_setosa <- model2DE(model = mod, model_type = "rf", data = iris[, -5]
, target = iris$Species, classPos = "setosa"
, filter = FALSE, discretize = TRUE, K = 3
, in_parallel = TRUE, n_cores = 2)
# Plot the decision ensemble:
# Plants from the setosa species have small petal and narrow long sepals.
plotFeatures(endo_setosa, levels_order = c("Low", "Medium", "High"))
plotNetwork(endo_setosa, hide_isolated_nodes = FALSE, layout = "fr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.