| Type: | Package |
| Title: | Analyze, Wrap, Explain: Modeling and Explainable Machine Learning |
| Version: | 0.2.3 |
| Description: | Provides a single, coherent workflow that carries a data set from import through exploratory data analysis, automatic model selection across a broad bank of regression and classification learners, model wrapping, ensembling, hyperparameter tuning, explainability (permutation importance, partial dependence, individual conditional expectation, and optional SHAP/LIME via 'DALEX'/'iml' when installed), evaluation, narrative storytelling, and reporting. The name 'awe' stands for the three pillars of the package: Analyze, Wrap, Explain. A single call to awe() returns an 'awe' object that can be summarized, plotted, explained, and reported with simple generic methods (summary(), plot(), explain(), report(), predict()). A consistent, 'ggplot2'-based visual identity (theme_awe(), awe_palette()) is used throughout, with base-graphics fallbacks so the package never requires a plotting dependency. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 3.6.0) |
| Imports: | stats, utils, graphics, grDevices, rpart |
| Suggests: | ggplot2, randomForest, ranger, xgboost, nnet, e1071, kernlab, glmnet, gbm, class, MASS, earth, pls, corrplot, rpart.plot, patchwork, gridExtra, scales, viridis, DALEX, iml, rmarkdown, knitr, testthat (≥ 3.0.0) |
| RoxygenNote: | 7.3.1 |
| VignetteBuilder: | knitr |
| URL: | https://github.com/olawaleawe/awe |
| BugReports: | https://github.com/olawaleawe/awe/issues |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-05 00:30:06 UTC; root |
| Author: | Olushina Olawale Awe
|
| Maintainer: | Olushina Olawale Awe <olawaleawe@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-29 10:30:02 UTC |
Analyze, Wrap, Explain: the end-to-end AWE pipeline
Description
A single call runs a data set through the whole analytical workflow:
explore -> preprocess -> select features -> model -> wrap -> explain ->
evaluate -> story. Each stage is also exported on its own
(awe_explore(), awe_preprocess(), awe_select_features(),
awe_model(), awe_wrap(), awe_explain(),
awe_evaluate(), awe_story()) for users who want to run or
customise individual steps – in the same spirit as caret's
train(), but covering the whole workflow rather than just fitting.
Usage
awe(
data,
target,
k = 5,
test_prop = 0.25,
stratify = TRUE,
select_features = FALSE,
top_n_features = NULL,
models = NULL,
explain = TRUE,
seed = 42,
verbose = interactive()
)
Arguments
data |
data.frame |
target |
character, name of the target/outcome column |
k |
number of cross-validation folds used for model selection |
test_prop |
proportion of data held out for evaluation |
stratify |
logical, whether the train/test split should be
stratified by the target (see |
select_features |
logical, whether to run automatic feature
selection (near-zero-variance + correlation filters, see
|
top_n_features |
optional integer cap on the number of predictors
kept by feature selection (by univariate association with the target);
|
models |
optional character vector restricting which model
candidates to try (see |
explain |
logical, whether to compute explanations (can be slow on large data; set to FALSE to skip) |
seed |
random seed used throughout for reproducibility |
verbose |
logical, whether to report progress and intermediate
results through |
Value
an object of class awe, a list with elements
data (the input data), target (the target name),
explore (an AWEExplore object), preprocess (the
train/test split, class AWEPreprocess), feature_selection
(an AWEFeatureSelection object, or NULL if skipped),
model (an AWEModel holding the cross-validated
leaderboard and every fitted candidate), wrapper (an
AWEWrapper around the best model), explainer (an
AWEExplainer, or NULL if skipped), evaluation (an
AWEEvaluation computed on the held-out test split), and
story (an AWEStory plain-language summary). Use
print(), summary(), plot(), predict(),
varImp(), explain() and report() to work with it.
Examples
fit <- awe(mtcars, target = "mpg", k = 3)
print(fit)
summary(fit)
Compare cross-validated leaderboards across multiple AWE runs
Description
Stacks the leaderboards of several awe_model (or
awe) results into one data.frame, tagged by run, so
different feature sets, preprocessing choices, or target definitions can
be compared side by side. See plot.AWECompare for a grouped
comparison chart.
Usage
awe_compare(..., labels = NULL)
Arguments
... |
two or more |
labels |
optional character vector of run labels (default:
|
Value
an object of class AWECompare
Examples
m1 <- awe_model(mtcars, target = "mpg", k = 3)
m2 <- awe_model(mtcars, target = "mpg", k = 3, models = c("linear_regression", "decision_tree"))
cmp <- awe_compare(full = m1, restricted = m2)
print(cmp)
Build a model ensemble from the top cross-validated candidates
Description
Combines the top top_n candidates from an awe_model
leaderboard into a single ensemble: a performance-weighted average for
continuous targets, or a performance-weighted majority vote for
classification targets. The result is an AWEWrapper (subclassed
AWEEnsemble) so it works everywhere a normal wrapper does –
predict(), awe_evaluate, awe_explain,
varImp.
Usage
awe_ensemble(model_result, top_n = 3)
Arguments
model_result |
an |
top_n |
how many of the best cross-validated candidates to combine |
Value
an object of class c("AWEEnsemble", "AWEWrapper")
Examples
m <- awe_model(mtcars, target = "mpg", k = 3)
ens <- awe_ensemble(m, top_n = 3)
print(ens)
predict(ens, newdata = mtcars[1:5, ])
Evaluate a wrapped model on held-out data
Description
Computes classification metrics (accuracy, precision, recall, F1, confusion matrix) or regression metrics (RMSE, MAE, MAPE, R-squared) depending on the target type.
Usage
awe_evaluate(wrapper, newdata)
Arguments
wrapper |
an |
newdata |
data.frame to evaluate on (e.g. a held-out test set) |
Value
an object of class AWEEvaluation
Explain a wrapped model
Description
Computes permutation feature importance and partial dependence /
individual conditional expectation curves using base R alone, so this
always works. When DALEX (and, for SHAP specifically, iml or
DALEX's own predict_parts) is installed, break-down/SHAP-style
local explanations are added automatically.
Usage
awe_explain(
wrapper,
newdata = NULL,
n_permutations = 5,
pdp_vars = NULL,
seed = 42
)
Arguments
wrapper |
an |
newdata |
optional data to explain on (defaults to training data) |
n_permutations |
number of permutation repeats for importance |
pdp_vars |
character vector of variables to compute PDP/ICE for (default: all predictors, capped at 8 for speed) |
seed |
random seed |
Value
an object of class AWEExplainer
Automatic exploratory data summary
Description
Produces a structured, no-decisions-required summary of a data set: dimensions, column types, missing values, outliers (IQR rule for numeric columns), skewness/kurtosis, and a simple correlation matrix for numeric columns.
Usage
awe_explore(data, target = NULL)
Arguments
data |
a data.frame |
target |
optional name of the target column, excluded from "predictor-only" diagnostics but still summarised |
Value
an object of class AWEExplore (a list)
Examples
e <- awe_explore(mtcars)
print(e)
Automatic model selection
Description
Trains a bank of candidate models appropriate to the detected target type
(continuous, binary, or multiclass), evaluates each with k-fold
cross-validation, and returns every fitted candidate plus the best one –
in the spirit of caret's train(), but with zero required
dependencies beyond base R and rpart.
Usage
awe_model(data, target, k = 5, models = NULL, seed = 42)
Arguments
data |
data.frame (already preprocessed, e.g. via
|
target |
character, name of the target column |
k |
number of cross-validation folds |
models |
optional character vector restricting which candidates to
try (by name, e.g. |
seed |
random seed |
Details
Candidates always include dependable base-R learners (lm/glm,
rpart trees, and a base-R k-NN) so the function never fails for
lack of a suggested package. When installed, the following are added
automatically as extra candidates: randomForest, ranger,
xgboost, nnet, e1071 (SVM, naive Bayes), kernlab
(SVM), glmnet (ridge/lasso/elastic net/regularized logistic),
gbm, class (k-NN classification), MASS (LDA/QDA/robust
regression), earth (MARS), and pls (partial least squares).
Routine engine warnings/messages (convergence notices, verbosity) are
silenced; genuine fitting failures still drop that one candidate with an
informative message. Use awe_registry to list every
candidate name available for a given target type without fitting
anything.
Value
an object of class AWEModel
Examples
m <- awe_model(mtcars, target = "mpg", k = 3)
print(m)
m2 <- awe_model(mtcars, target = "mpg", k = 3, models = c("linear_regression", "decision_tree"))
AWE colour palette and ggplot2 theme
Description
A small, consistent visual identity used across every plotting function
in the package: a deep-green/gold palette (awe_palette()) and a
clean ggplot2 theme (theme_awe()) built on
theme_minimal() with refined gridlines, spacing, and typography.
Both are exported so users can reuse them in their own ggplot2
plots.
Usage
awe_palette(n = 6)
theme_awe(base_size = 11)
Arguments
n |
number of colours requested (recycled if larger than the base palette) |
base_size |
base font size passed to |
Value
awe_palette(): a character vector of hex colours.
theme_awe(): a ggplot2 theme object.
Examples
awe_palette(3)
Lightweight automatic preprocessing
Description
Median/mode-imputes missing values, drops zero-variance columns, and
returns a train/test split ready for modelling. This intentionally stays
simple (no external dependency) so that awe() always works with
base R alone; heavier pipelines (recipes, tidymodels) can be plugged in
by preprocessing the data before calling awe().
Usage
awe_preprocess(data, target, test_prop = 0.25, stratify = TRUE, seed = 42)
Arguments
data |
data.frame |
target |
character, name of the target column |
test_prop |
proportion of rows held out for testing |
stratify |
logical, whether to stratify the train/test split by the
target. For binary/multiclass targets this samples |
seed |
random seed for the split |
Value
a list with train, test, and dropped_vars
Examples
sp <- awe_preprocess(iris, target = "Species", stratify = TRUE)
prop.table(table(sp$train$Species))
prop.table(table(sp$test$Species))
List available model candidate names
Description
Returns the names of every model candidate awe_model would
try for a given target type, without fitting anything, distinguishing
candidates that are always available (base R) from ones added only when
an optional package is installed.
Usage
awe_registry(target_type = c("continuous", "binary", "multiclass"))
Arguments
target_type |
one of |
Value
a data.frame with columns model and requires
Examples
awe_registry("continuous")
Generate a report from an AWE analysis
Description
Writes a self-contained Markdown report (always available) and, when rmarkdown (plus a working Pandoc) is installed, renders it to HTML as well.
Usage
awe_report(
x,
file = file.path(tempdir(), "awe_report"),
format = c("md", "html")
)
Arguments
x |
an |
file |
output file path without extension (default: "awe_report" in
|
format |
one of "md", "html" |
Value
invisibly, the path to the generated file
Save/load an AWE object to/from disk
Description
Thin, discoverable wrappers around saveRDS()/readRDS() for
persisting any awe, AWEModel, AWEWrapper, or other
AWE object between R sessions.
Usage
awe_save(x, file)
awe_load(file)
Arguments
x |
an AWE object to save |
file |
path to write to / read from ( |
Value
awe_save(): invisibly, file. awe_load(): the
restored object.
Examples
m <- awe_model(mtcars, target = "mpg", k = 3)
f <- tempfile(fileext = ".rds")
awe_save(m, f)
m2 <- awe_load(f)
identical(m$best_name, m2$best_name)
Automatic feature selection
Description
Screens predictors using up to three filters, in the spirit of
caret's nearZeroVar() / findCorrelation():
-
Near-zero-variance: drops predictors that are almost constant (a small number of unique values, one of which dominates).
-
Correlation: among numeric predictors, drops one of any pair correlated above
corr_cutoff(keeping the one with lower mean absolute correlation to the rest). -
Univariate association with the target: scores every remaining predictor's association with the target (correlation for numeric-numeric, ANOVA F-statistic for numeric-categorical or categorical-numeric, Cramer's V for categorical-categorical) and optionally keeps only the top
top_n.
Usage
awe_select_features(
data,
target,
nzv = TRUE,
freq_cutoff = 19,
unique_cutoff = 10,
correlation = TRUE,
corr_cutoff = 0.9,
top_n = NULL
)
Arguments
data |
data.frame |
target |
character, name of the target column (excluded from filtering; used only for the univariate scores) |
nzv |
logical, apply the near-zero-variance filter |
freq_cutoff |
ratio of the most common to second-most-common value above which a predictor is flagged as near-zero-variance |
unique_cutoff |
percentage of unique values below which a predictor is flagged as near-zero-variance |
correlation |
logical, apply the pairwise correlation filter |
corr_cutoff |
absolute correlation above which one of a pair of numeric predictors is dropped |
top_n |
optional integer, keep only the top |
Value
an object of class AWEFeatureSelection: a list with
selected (character vector of kept predictors), dropped
(named list of dropped variables per filter), scores (data.frame
of univariate scores), and data (the input data subset to the
selected predictors plus the target)
Examples
fs <- awe_select_features(mtcars, target = "mpg", top_n = 5)
fs$selected
Turn an AWE analysis into a plain-language narrative
Description
Automatically drafts an executive summary, key findings, and
recommendations from the exploratory summary, model leaderboard,
explainer, and evaluation components of an awe analysis.
Usage
awe_story(x)
Arguments
x |
an |
Value
an object of class AWEStory, and invisibly its text
Hyperparameter tuning by grid search
Description
A light-weight, dependency-free (beyond the modelling engine itself)
grid-search tuner, in the spirit of caret's train() with a
tuneGrid. Cross-validates every combination of hyperparameters in
grid and refits the best combination on the full data set.
Usage
awe_tune(
data,
target,
model = c("decision_tree", "random_forest", "glmnet", "svm_radial"),
grid = NULL,
k = 5,
seed = 42
)
Arguments
data |
data.frame |
target |
character, name of the target column |
model |
one of |
grid |
optional data.frame of hyperparameter combinations to try
(column names depend on |
k |
number of cross-validation folds |
seed |
random seed |
Value
an object of class AWETune with results (the grid
plus CV scores), best_params, and wrapper (an
AWEWrapper fit with the best hyperparameters on the full data)
Examples
tn <- awe_tune(mtcars, target = "mpg", model = "decision_tree", k = 3)
tn$best_params
Wrap a fitted model into a common AWEWrapper interface
Description
Bundles a fitted model together with its training data, prediction
function, target name, and metadata into a single object with a
consistent predict() method, regardless of which underlying
engine (lm, glm, rpart, randomForest, xgboost, ...) produced it. This is
what the rest of the "wrap" and "explain" pipeline operates on.
Usage
awe_wrap(
model_result,
which = NULL,
data = NULL,
target = NULL,
predict_fn = NULL
)
Arguments
model_result |
an |
which |
character, name of a specific candidate to wrap instead of
the overall best model (only used when |
data |
data.frame used for training (required if |
target |
character target name (required if |
predict_fn |
optional custom prediction function
|
Value
an object of class AWEWrapper
Examples
m <- awe_model(mtcars, target = "mpg", k = 3)
w <- awe_wrap(m) # wraps the best model
w_tree <- awe_wrap(m, which = "decision_tree") # wraps a specific candidate
Automatic bivariate EDA against a target variable
Description
Detects the type of each predictor and the target and chooses an appropriate paired plot: scatter (numeric x numeric), boxplot (numeric x categorical), or a mosaic-style proportion bar chart (categorical x categorical).
Usage
eda_bivariate(data, target, vars = NULL, max_vars = 12)
Arguments
data |
data.frame |
target |
character, name of the target column |
vars |
optional character vector of predictors (default: all others) |
max_vars |
safety cap on the number of plots produced |
Value
A named list with one element per plotted predictor, returned
invisibly. With ggplot2 installed each element is a ggplot
object showing that predictor against the target (scatter plot, boxplot
or proportion bar chart depending on the variable types) and is drawn
only when printed. Without ggplot2 the plots are drawn immediately
with base graphics and the list is empty.
Combined multi-panel EDA overview
Description
Arranges eda_univariate plots for several variables into a
single multi-panel figure using patchwork (or gridExtra as a
fallback) when ggplot2 is available, for a quick visual overview of
a data set's distributions in one call.
Usage
eda_report(data, vars = NULL, max_vars = 9, ncol = 3)
Arguments
data |
data.frame |
vars |
optional character vector of columns to plot (default: all) |
max_vars |
safety cap on number of panels |
ncol |
number of columns in the panel grid |
Value
the combined plot object (invisibly, if only base graphics are
available, in which case panels are drawn directly via par(mfrow))
Automatic univariate EDA
Description
Chooses an appropriate plot for every column: histogram + density for numeric variables, bar plot for categorical variables. Uses ggplot2 when installed, and falls back to base graphics otherwise, so the function never fails purely for lack of a suggested plotting package.
Usage
eda_univariate(data, vars = NULL, max_vars = 12)
Arguments
data |
data.frame |
vars |
optional character vector of columns to plot (default: all) |
max_vars |
safety cap on number of plots produced in one call |
Value
invisibly, a list of the plot objects (ggplot objects if ggplot2 is available, otherwise NULL, since base plots draw directly to the graphics device)
Explain generic
Description
Explain generic
Usage
explain(x, ...)
Arguments
x |
object to explain |
... |
additional arguments passed to methods |
Value
Depends on the method. For an awe object, an AWEExplainer
(see awe_explain): a list holding the permutation
importance table and the partial-dependence and ICE curves for the most
important variables.
Grouped bar chart comparing model leaderboards across runs
Description
Grouped bar chart comparing model leaderboards across runs
Usage
## S3 method for class 'AWECompare'
plot(x, ...)
Arguments
x |
an |
... |
unused |
Value
A ggplot object (grouped bar chart with error bars) when
ggplot2 is installed. Otherwise the chart is drawn with base
graphics and the stacked leaderboard data.frame is returned invisibly.
Bars give each model's mean cross-validated score in each run, so runs
can be compared model by model.
Plot an AWE explainer
Description
Plot an AWE explainer
Usage
## S3 method for class 'AWEExplainer'
plot(x, type = c("importance", "pdp"), var = NULL, top_n = 15, ...)
Arguments
x |
an |
type |
|
var |
variable name, used when |
top_n |
how many variables to show when |
... |
unused |
Value
For type = "importance" or type = "pdp", a ggplot
object when ggplot2 is installed; otherwise the plot is drawn with
base graphics and the explainer is returned invisibly. The importance
plot shows the increase in loss when each variable is shuffled (larger
means more important). The partial-dependence plot shows the average
prediction across the variable's range (bold line) over faint
individual (ICE) curves, one per observation.
Plot an AWE analysis
Description
Plot an AWE analysis
Usage
## S3 method for class 'awe'
plot(
x,
type = c("importance", "pdp", "leaderboard", "tree", "roc", "confusion", "residuals"),
var = NULL,
which = "decision_tree",
...
)
Arguments
x |
an |
type |
one of |
var |
variable name, used when |
which |
candidate model name, used when |
... |
passed on to the underlying plot method |
Value
The plot produced for the chosen type, as returned by the
underlying function: a ggplot object for "importance",
"pdp", "leaderboard" and "confusion"; an
AWEROC object for "roc"; a ggplot or patchwork
object for "residuals"; and, for "tree", the fitted
rpart model returned invisibly after the tree is drawn. See
plot_leaderboard, plot_roc,
plot_confusion, plot_residuals and
plot_tree for what each shows.
Confusion-matrix heatmap
Description
Confusion-matrix heatmap
Usage
plot_confusion(evaluation)
Arguments
evaluation |
an |
Value
A ggplot object (tile heatmap with the count in each cell) when
ggplot2 is installed. Otherwise a mosaic plot is drawn with base
graphics and the confusion table is returned invisibly. Rows are actual
classes, columns are predicted classes, and the diagonal holds the
correctly classified cases.
Correlation heatmap
Description
Correlation heatmap
Usage
plot_correlation(data, vars = NULL)
Arguments
data |
data.frame |
vars |
optional character vector of numeric columns (default: all numeric columns) |
Value
A ggplot object (heatmap with the correlation printed in each
cell) when ggplot2 is installed. Otherwise the heatmap is drawn
with corrplot or base graphics as a side effect and the numeric
correlation matrix is returned invisibly. Each value is the pairwise
Pearson correlation between two variables, from -1 (perfect negative
association) to 1 (perfect positive association).
Feature-selection score plot
Description
Feature-selection score plot
Usage
plot_feature_selection(fs, top_n = 15)
Arguments
fs |
an |
top_n |
how many top-scoring variables to display |
Value
A ggplot object (bar chart) when ggplot2 is installed.
Otherwise the chart is drawn with base graphics and a data.frame of the
plotted scores (columns variable, score, and a logical
selected) is returned invisibly. Each bar is a predictor's
univariate association score with the target; bars for predictors that
were selected are drawn in the darker colour.
Model leaderboard comparison plot
Description
Model leaderboard comparison plot
Usage
plot_leaderboard(model_result)
Arguments
model_result |
an |
Value
A ggplot object (horizontal bar chart) when ggplot2 is
installed. Otherwise the chart is drawn with base graphics and the
leaderboard data.frame is returned invisibly. Each bar is a candidate
model's mean cross-validated score (RMSE for continuous targets,
accuracy for classification) with error bars of one standard deviation
across folds, and the best model is highlighted.
Missing-value overview plot
Description
Missing-value overview plot
Usage
plot_missingness(data)
Arguments
data |
data.frame |
Value
A ggplot object (horizontal bar chart) when ggplot2 is
installed. Otherwise the chart is drawn with base graphics and a
data.frame with columns variable and pct_missing is
returned invisibly. Each bar is the percentage of missing values in one
variable, ordered from most to least missing.
Regression diagnostic plots: residuals vs fitted, and a normal Q-Q plot
Description
Regression diagnostic plots: residuals vs fitted, and a normal Q-Q plot
Usage
plot_residuals(wrapper, newdata = NULL)
Arguments
wrapper |
an |
newdata |
data to evaluate on (default: the wrapper's training data) |
Value
A ggplot (patchwork) object with a residuals-versus-fitted panel
and a normal Q-Q panel when ggplot2 and patchwork are
installed; a list of class AWEPlotList holding the two
ggplots when only ggplot2 is installed (printing it draws
both); or, with neither, a base-graphics plot drawn as a side effect and
a data.frame of fitted values and residuals returned invisibly.
Residuals are observed minus predicted values, so a good model shows no
pattern in the first panel and points close to the line in the second.
ROC curve and AUC for a binary classifier
Description
Computes a receiver operating characteristic curve from a fitted
AWEWrapper using its native class probabilities when the engine
supplies them (see names(awe_registry("binary")) for which do),
falling back to hard 0/1 predictions otherwise. AUC is computed
rank-based (Mann-Whitney U), no extra dependency required.
Usage
plot_roc(wrapper, newdata = NULL, positive = NULL)
Arguments
wrapper |
an |
newdata |
data to evaluate on (default: the wrapper's training data) |
positive |
the level treated as the positive class (default: the second factor level) |
Value
An object of class AWEROC, a list with elements roc (a
data.frame of false-positive rate fpr and true-positive rate
tpr along the curve), auc (the area under the curve, from
0.5 for chance to 1 for perfect separation), positive (the
positive class) and plot (a ggplot object, or NULL
if ggplot2 is not installed). Printing the object, which happens
automatically at the console, draws the ROC curve.
Plot a decision tree from an AWE model
Description
Visualises a fitted rpart tree candidate (rpart.plot if
installed, base rpart plotting otherwise).
Usage
plot_tree(x, which = "decision_tree")
Arguments
x |
an |
which |
which candidate to plot if |
Value
Called for its side effect of drawing the tree. Returns the fitted
rpart model invisibly, so the underlying tree can be inspected
further.
Report generic
Description
Report generic
Usage
report(x, ...)
Arguments
x |
object to report on |
... |
additional arguments passed to methods |
Value
Depends on the method. For an awe object, invisibly, the path to
the generated report file (see awe_report); the report is
written to disk and nothing else is returned.
Variable importance
Description
A caret-style varImp() generic. Uses each engine's native
importance measure when available (e.g. $variable.importance for
rpart, importance() for randomForest, absolute
t-values for lm/glm), and falls back to permutation
importance (awe_explain) for any other model type.
Usage
varImp(object, ...)
## S3 method for class 'AWEWrapper'
varImp(object, ...)
## S3 method for class 'awe'
varImp(object, ...)
Arguments
object |
model or wrapper object |
... |
additional arguments passed to methods |
Value
a data.frame with columns variable and importance,
sorted descending