Skip to content

Commit 294062f

Browse files
committed
fixing NOTEs and WARNINGs from CRAN
1 parent d58b2a3 commit 294062f

17 files changed

+135
-111
lines changed

DALEX.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version: 1.0
2+
ProjectId: 4d8b6bf2-cb61-4abb-a60f-33d25cb458e9
23

34
RestoreWorkspace: No
45
SaveWorkspace: No

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: DALEX
22
Title: moDel Agnostic Language for Exploration and eXplanation
3-
Version: 2.5.1
3+
Version: 2.5.2
44
Authors@R: c(person("Przemyslaw", "Biecek", email = "[email protected]", role = c("aut", "cre"),
55
comment = c(ORCID = "0000-0001-8423-1823")),
66
person("Szymon", "Maksymiuk", role = "aut",
@@ -22,7 +22,7 @@ Description: Any unverified black box model is the path to failure. Opaqueness l
2222
License: GPL
2323
Encoding: UTF-8
2424
LazyData: true
25-
RoxygenNote: 7.2.3
25+
RoxygenNote: 7.3.2
2626
Depends: R (>= 3.5)
2727
Imports:
2828
ggplot2,

NAMESPACE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ S3method(plot,list)
1717
S3method(plot,model_diagnostics)
1818
S3method(plot,model_parts)
1919
S3method(plot,model_performance)
20+
S3method(plot,model_performance_boxplot)
21+
S3method(plot,model_performance_ecdf)
22+
S3method(plot,model_performance_gain)
23+
S3method(plot,model_performance_histogram)
24+
S3method(plot,model_performance_lift)
25+
S3method(plot,model_performance_prc)
26+
S3method(plot,model_performance_roc)
2027
S3method(plot,model_profile)
28+
S3method(plot,model_profile_aggregates)
29+
S3method(plot,model_profile_points)
30+
S3method(plot,model_profile_profiles)
2131
S3method(plot,predict_diagnostics)
2232
S3method(plot,predict_parts)
2333
S3method(plot,predict_profile)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
DALEX 2.5.2
2+
---------------------------------------------------------------
3+
* fixed NOTE during `devtools::document()` such as `S3 method plot.... needs @export or @exportS3method tag.`
4+
15
DALEX 2.5.1
26
---------------------------------------------------------------
37
* adding the support for calculating kernel SHAP values via `predict_parts()` function

R/data_happiness.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' World Happiness Report data
22
#'
33
#' The \code{happiness_train} and \code{happiness_test} datasets are generated
4-
#' based on the "World Happiness Report" at Kaggle \url{https://www.kaggle.com/datasets/unsdsn/world-happiness}.
4+
#' based on the "World Happiness Report".
55
#'
66
#' It contains data for 781 countries and 7 variables. These are:
77
#' \itemize{
@@ -19,7 +19,7 @@
1919
#' @name happiness
2020
#' @aliases happiness_test happiness_train
2121
#'
22-
#' @source World Happiness Report data \url{https://worldhappiness.report/}
22+
#' @source World Happiness Report data
2323
#' @usage
2424
#' data(happiness_train)
2525
#' data(happiness_test)

R/data_titanic.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#' @source This dataset was copied from the \code{stablelearner} package and went through few variable
4343
#' transformations. The complete list of persons on the RMS titanic was downloaded from
4444
#' \url{https://www.encyclopedia-titanica.org} on April 5, 2016. The information given
45-
#' in \code{sibsp} and \code{parch} was adopoted from a data set obtained from \url{https://biostat.app.vumc.org/wiki/Main/DataSets}.
45+
#' in \code{sibsp} and \code{parch} was adopoted from a data set obtained from \code{Kaggle}.
4646
#' @usage
4747
#' data(titanic)
4848
#' data(titanic_imputed)

R/plot_model_parts.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#'
1010
#' \subsection{variable_importance}{
1111
#' \itemize{
12-
#' \item{\code{max_vars}}{ maximal number of features to be included in the plot. default value is \code{10}}
13-
#' \item{\code{show_boxplots}}{ logical if \code{TRUE} (default) boxplot will be plotted to show permutation data.}
14-
#' \item{\code{bar_width}}{ width of bars. By default \code{10}}
15-
#' \item{\code{desc_sorting}}{ logical. Should the bars be sorted descending? By default \code{TRUE}}
16-
#' \item{\code{title}}{ the plot's title, by default \code{'Feature Importance'}}
17-
#' \item{\code{subtitle}}{ a character. Plot subtitle. By default \code{NULL} - then subtitle is set to "created for the XXX, YYY model",
12+
#' \item{\code{max_vars} -- maximal number of features to be included in the plot. default value is \code{10}}
13+
#' \item{\code{show_boxplots} -- logical if \code{TRUE} (default) boxplot will be plotted to show permutation data.}
14+
#' \item{\code{bar_width} -- width of bars. By default \code{10}}
15+
#' \item{\code{desc_sorting} -- logical. Should the bars be sorted descending? By default \code{TRUE}}
16+
#' \item{\code{title} -- the plot's title, by default \code{'Feature Importance'}}
17+
#' \item{\code{subtitle} -- a character. Plot subtitle. By default \code{NULL} - then subtitle is set to "created for the XXX, YYY model",
1818
#' where XXX, YYY are labels of given explainers.}
1919
#' }
2020
#' }

R/plot_model_performance.R

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#' plot(mp_ranger, mp_glm, mp_lm, geom = "boxplot", show_outliers = 1)
5555
#' }
5656
#'
57+
#' @export
5758
#
5859
plot.model_performance <- function(x, ..., geom = "ecdf", show_outliers = 0, ptlabel = "name", lossFunction = loss_function, loss_function = function(x) sqrt(mean(x^2))) {
5960
if (!(ptlabel %in% c("name", "index"))){
@@ -96,10 +97,10 @@ plot.model_performance <- function(x, ..., geom = "ecdf", show_outliers = 0, ptl
9697
)
9798
}
9899

99-
100-
plot.model_performance_ecdf <- function(df, nlabels) {
100+
#' @export
101+
plot.model_performance_ecdf <- function(x, nlabels, ...) {
101102
label <- name <- NULL
102-
ggplot(df, aes(abs(diff), color = label)) +
103+
ggplot(x, aes(abs(diff), color = label)) +
103104
stat_ecdf(geom = "step") +
104105
theme_default_dalex() +
105106
scale_color_manual(name = "Model", values = colors_discrete_drwhy(nlabels)) +
@@ -111,23 +112,24 @@ plot.model_performance_ecdf <- function(df, nlabels) {
111112
ggtitle(expression(paste("Reverse cumulative distribution of ", group("|", residual, "|"))))
112113
}
113114

114-
plot.model_performance_boxplot <- function(df, show_outliers, loss_function, nlabels) {
115+
#' @export
116+
plot.model_performance_boxplot <- function(x, show_outliers, loss_function, nlabels, ...) {
115117
label <- name <- NULL
116-
pl <- ggplot(df, aes(x = label, y = abs(diff), fill = label)) +
118+
pl <- ggplot(x, aes(x = label, y = abs(diff), fill = label)) +
117119
stat_boxplot(alpha = 0.4, coef = 1000) +
118120
stat_summary(fun = loss_function, geom = "point", shape = 20, size=10, color="red", fill="red") +
119121
theme_vertical_default_dalex() +
120122
scale_fill_manual(name = "Model", values = colors_discrete_drwhy(nlabels)) +
121123
ylab("") +
122-
scale_x_discrete("", limits = rev(levels(df$label))) + # added to fix https://github.com/ModelOriented/DALEX/issues/400
124+
scale_x_discrete("", limits = rev(levels(x$label))) + # added to fix https://github.com/ModelOriented/DALEX/issues/400
123125
ggtitle(
124126
expression(paste("Boxplots of ", group("|", residual, "|"))),
125127
"Red dot stands for root mean square of residuals"
126128
) +
127129
coord_flip()
128130
if (show_outliers > 0) {
129-
df$rank <- unlist(tapply(-abs(df$diff), df$label, rank, ties.method = "min"))
130-
df_small <- df[df$rank <= show_outliers,]
131+
x$rank <- unlist(tapply(-abs(x$diff), x$label, rank, ties.method = "min"))
132+
df_small <- x[x$rank <= show_outliers,]
131133
pl <- pl +
132134
geom_point(data = df_small) +
133135
geom_text(data = df_small,
@@ -137,13 +139,14 @@ plot.model_performance_boxplot <- function(df, show_outliers, loss_function, nla
137139
pl
138140
}
139141

140-
plot.model_performance_histogram <- function(df, nlabels) {
142+
#' @export
143+
plot.model_performance_histogram <- function(x, nlabels, ...) {
141144
diff <- label <- NULL
142145
# commented to keep it consistent with other plots
143146
# see: https://github.com/ModelOriented/DALEX/issues/400
144147
# if (length(levels(df$label)) > 1) levels(df$label) <- rev(levels(df$label))
145148

146-
ggplot(df, aes(diff, fill = label)) +
149+
ggplot(x, aes(diff, fill = label)) +
147150
geom_histogram(bins = 100) +
148151
facet_wrap(~label, ncol = 1) +
149152
theme_default_dalex() + xlab("residuals") + theme(legend.position = "none") +
@@ -153,8 +156,9 @@ plot.model_performance_histogram <- function(df, nlabels) {
153156
}
154157

155158
# precision-recall curve
156-
plot.model_performance_prc <- function(df, nlabels) {
157-
dfl <- split(df, factor(df$label))
159+
#' @export
160+
plot.model_performance_prc <- function(x, nlabels, ...) {
161+
dfl <- split(x, factor(x$label))
158162
prcdfl <- lapply(dfl, function(df) {
159163
pred_sorted <- df[order(df$predicted, decreasing = TRUE), ]
160164

@@ -178,8 +182,9 @@ plot.model_performance_prc <- function(df, nlabels) {
178182
}
179183

180184
# receiver operating characteristic
181-
plot.model_performance_roc <- function(df, nlabels) {
182-
dfl <- split(df, factor(df$label))
185+
#' @export
186+
plot.model_performance_roc <- function(x, nlabels, ...) {
187+
dfl <- split(x, factor(x$label))
183188
rocdfl <- lapply(dfl, function(df) {
184189
# assuming that y = 0/1 where 1 is the positive
185190
tpr_tmp <- tapply(df$observed, df$predicted, sum)
@@ -203,8 +208,9 @@ plot.model_performance_roc <- function(df, nlabels) {
203208
ggtitle("Receiver Operator Characteristic")
204209
}
205210

206-
plot.model_performance_gain <- function(df, nlabels) {
207-
dfl <- split(df, factor(df$label))
211+
#' @export
212+
plot.model_performance_gain <- function(x, nlabels, ...) {
213+
dfl <- split(x, factor(x$label))
208214
rocdfl <- lapply(dfl, function(df) {
209215
pred_sorted <- df[order(df$predicted, decreasing = TRUE), ]
210216

@@ -214,7 +220,7 @@ plot.model_performance_gain <- function(df, nlabels) {
214220
data.frame(lift = lift, pr = pr, label = df$label[1])
215221
})
216222
rocdf <- do.call(rbind, rocdfl)
217-
max_lift <- sum(df$observed)/nrow(df)
223+
max_lift <- sum(x$observed)/nrow(x)
218224

219225
pr <- lift <- label <- NULL
220226
ggplot(rocdf, aes(x = pr, y = lift, color = label)) +
@@ -228,9 +234,9 @@ plot.model_performance_gain <- function(df, nlabels) {
228234

229235
}
230236

231-
232-
plot.model_performance_lift <- function(df, nlabels) {
233-
dfl <- split(df, factor(df$label))
237+
#' @export
238+
plot.model_performance_lift <- function(x, nlabels, ...) {
239+
dfl <- split(x, factor(x$label))
234240
rocdfl <- lapply(dfl, function(df) {
235241
pred_sorted <- df[order(df$predicted, decreasing = TRUE), ]
236242

@@ -240,7 +246,7 @@ plot.model_performance_lift <- function(df, nlabels) {
240246
data.frame(lift = lift/pr, pr = pr, label = df$label[1])
241247
})
242248
rocdf <- do.call(rbind, rocdfl)
243-
max_lift <- sum(df$observed)/nrow(df)
249+
max_lift <- sum(x$observed)/nrow(x)
244250

245251
pr <- lift <- label <- NULL
246252
ggplot(rocdf, aes(x = pr, y = lift/max_lift, color = label)) +

R/plot_model_profile.R

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#'
99
#' \subsection{aggregates}{
1010
#' \itemize{
11-
#' \item{\code{color}}{ a character. Either name of a color, or hex code for a color,
11+
#' \item{\code{color} -- a character. Either name of a color, or hex code for a color,
1212
#' or \code{_label_} if models shall be colored, or \code{_ids_} if instances shall be colored}
13-
#' \item{\code{size}}{ a numeric. Size of lines to be plotted}
14-
#' \item{\code{alpha}}{ a numeric between \code{0} and \code{1}. Opacity of lines}
15-
#' \item{\code{facet_ncol}}{ number of columns for the \code{\link[ggplot2]{facet_wrap}}}
16-
#' \item{\code{variables}}{ if not \code{NULL} then only \code{variables} will be presented}
17-
#' \item{\code{title}}{ a character. Partial and accumulated dependence explainers have deafult value.}
18-
#' \item{\code{subtitle}}{ a character. If \code{NULL} value will be dependent on model usage.}
13+
#' \item{\code{size} -- a numeric. Size of lines to be plotted}
14+
#' \item{\code{alpha} -- a numeric between \code{0} and \code{1}. Opacity of lines}
15+
#' \item{\code{facet_ncol} -- number of columns for the \code{\link[ggplot2]{facet_wrap}}}
16+
#' \item{\code{variables} -- if not \code{NULL} then only \code{variables} will be presented}
17+
#' \item{\code{title} -- a character. Partial and accumulated dependence explainers have deafult value.}
18+
#' \item{\code{subtitle} -- a character. If \code{NULL} value will be dependent on model usage.}
1919
#' }
2020
#' }
2121
#'
@@ -63,6 +63,7 @@ plot.model_profile <- function(x, ..., geom = "aggregates") {
6363
)
6464
}
6565

66+
#' @export
6667
plot.model_profile_aggregates <- function(x, ...) {
6768
# plot(x$agr_profiles, ..., color = x$color)
6869
# fix for https://github.com/ModelOriented/DALEX/issues/237
@@ -73,11 +74,13 @@ plot.model_profile_aggregates <- function(x, ...) {
7374
do.call(plot, tmp)
7475
}
7576

77+
#' @export
7678
plot.model_profile_profiles <- function(x, ...) {
7779
plot(x$cp_profiles, ..., size = 0.5, color = "grey") +
7880
ingredients::show_aggregated_profiles(x$agr_profiles, ..., size = 2, color = x$color)
7981
}
8082

83+
#' @export
8184
plot.model_profile_points <- function(x, ...) {
8285
plot(x$cp_profiles, ..., color = "grey", size = 0.5) +
8386
ingredients::show_aggregated_profiles(x$agr_profiles, ..., size = 2, color = x$color) +

R/plot_predict_parts.R

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@
99
#'
1010
#' \subsection{break_down}{
1111
#' \itemize{
12-
#' \item{\code{max_features}}{ maximal number of features to be included in the plot. default value is \code{10}}
13-
#' \item{\code{min_max}}{ a range of OX axis. By default \code{NA}, therefore it will be extracted from the contributions of \code{x}.
12+
#' \item{\code{max_features} -- maximal number of features to be included in the plot. default value is \code{10}}
13+
#' \item{\code{min_max} -- a range of OX axis. By default \code{NA}, therefore it will be extracted from the contributions of \code{x}.
1414
#' But it can be set to some constants, useful if these plots are to be used for comparisons.}
15-
#' \item{\code{add_contributions}}{ if \code{TRUE}, variable contributions will be added to the plot.}
16-
#' \item{\code{shift_contributions}}{ number describing how much labels should be shifted to the right, as a fraction of range. By default equal to \code{0.05}.}
17-
#' \item{\code{vcolors}}{ If \code{NA} (default), DrWhy colors are used.}
18-
#' \item{\code{vnames}}{ a character vector, if specified then will be used as labels on OY axis. By default \code{NULL}.}
19-
#' \item{\code{digits}}{ number of decimal places (\code{\link{round}}) or significant digits (\code{\link{signif}}) to be used.}
20-
#' \item{\code{rounding_function}}{ a function to be used for rounding numbers.}
21-
#' \item{\code{plot_distributions}}{ if \code{TRUE} then distributions of conditional propotions will be plotted. This requires \code{keep_distributions=TRUE} in the
22-
#' \code{\link{break_down}}, \code{\link{local_attributions}}, or \code{\link{local_interactions}}.}
23-
#' \item{\code{baseline}}{ if numeric then veritical line starts in \code{baseline}.}
24-
#' \item{\code{title}}{ a character. Plot title. By default \code{"Break Down profile"}.}
25-
#' \item{\code{subtitle}}{ a character. Plot subtitle. By default \code{NULL} - then subtitle is set to "created for the XXX, YYY model",
15+
#' \item{\code{add_contributions} -- if \code{TRUE}, variable contributions will be added to the plot.}
16+
#' \item{\code{shift_contributions} -- number describing how much labels should be shifted to the right, as a fraction of range. By default equal to \code{0.05}.}
17+
#' \item{\code{vcolors} -- If \code{NA} (default), DrWhy colors are used.}
18+
#' \item{\code{vnames} -- a character vector, if specified then will be used as labels on OY axis. By default \code{NULL}.}
19+
#' \item{\code{digits} -- number of decimal places (\code{\link{round}}) or significant digits (\code{\link{signif}}) to be used.}
20+
#' \item{\code{rounding_function} -- a function to be used for rounding numbers.}
21+
#' \item{\code{plot_distributions} -- if \code{TRUE} then distributions of conditional propotions will be plotted. This requires \code{keep_distributions=TRUE} in the
22+
#' \code{break_down}, \code{local_attributions}, or \code{local_interactions}.}
23+
#' \item{\code{baseline} -- if numeric then veritical line starts in \code{baseline}.}
24+
#' \item{\code{title} -- a character. Plot title. By default \code{"Break Down profile"}.}
25+
#' \item{\code{subtitle} -- a character. Plot subtitle. By default \code{NULL} - then subtitle is set to "created for the XXX, YYY model",
2626
#' where XXX, YYY are labels of given explainers.}
27-
#' \item{\code{max_vars}}{ alias for the \code{max_features} parameter.}
27+
#' \item{\code{max_vars} -- alias for the \code{max_features} parameter.}
2828
#' }
2929
#' }
3030
#' \subsection{shap}{
3131
#' \itemize{
32-
#' \item{\code{show_boxplots}}{ logical if \code{TRUE} (default) boxplot will be plotted to show uncertanity of attributions.}
33-
#' \item{\code{vcolors}}{ If \code{NA} (default), DrWhy colors are used.}
34-
#' \item{\code{max_features}}{ maximal number of features to be included in the plot. default value is \code{10}}
35-
#' \item{\code{max_vars}}{ alias for the \code{max_features} parameter.}
32+
#' \item{\code{show_boxplots} -- logical if \code{TRUE} (default) boxplot will be plotted to show uncertanity of attributions.}
33+
#' \item{\code{vcolors} -- If \code{NA} (default), DrWhy colors are used.}
34+
#' \item{\code{max_features} -- maximal number of features to be included in the plot. default value is \code{10}}
35+
#' \item{\code{max_vars} -- alias for the \code{max_features} parameter.}
3636
#' }
3737
#' }
3838
#' \subsection{oscillations}{
3939
#' \itemize{
40-
#' \item{\code{bar_width}}{ width of bars. By default \code{10}}
40+
#' \item{\code{bar_width} -- width of bars. By default \code{10}}
4141
#' }
4242
#' }
4343
#'

0 commit comments

Comments
 (0)