Skip to content

Commit 0fb5145

Browse files
committed
update model
1 parent f2da2ad commit 0fb5145

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: performance
33
Title: Assessment of Regression Models Performance
4-
Version: 0.11.0.6
4+
Version: 0.11.0.7
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

R/check_distribution.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ NULL
3434
#' This function uses an internal random forest model to classify the
3535
#' distribution from a model-family. Currently, following distributions are
3636
#' trained (i.e. results of `check_distribution()` may be one of the
37-
#' following): `"bernoulli"`, `"beta"`, `"beta-binomial"`,
38-
#' `"binomial"`, `"chi"`, `"exponential"`, `"F"`,
39-
#' `"gamma"`, `"lognormal"`, `"normal"`, `"negative
40-
#' binomial"`, `"negative binomial (zero-inflated)"`, `"pareto"`,
41-
#' `"poisson"`, `"poisson (zero-inflated)"`, `"uniform"` and
42-
#' `"weibull"`.
37+
#' following): `"bernoulli"`, `"beta"`, `"beta-binomial"`, `"binomial"`,
38+
#' `"cauchy"`, `"chi"`, `"exponential"`, `"F"`, `"gamma"`, `"half-cauchy"`,
39+
#' `"inverse-gamma"`, `"lognormal"`, `"normal"`, `"negative binomial"`,
40+
#' `"negative binomial (zero-inflated)"`, `"pareto"`, `"poisson"`,
41+
#' `"poisson (zero-inflated)"`, `"tweedie"`, `"uniform"` and `"weibull"`.
4342
#' \cr \cr
4443
#' Note the similarity between certain distributions according to shape, skewness,
4544
#' etc. Thus, the predicted distribution may not be perfectly representing the
@@ -222,6 +221,7 @@ check_distribution.numeric <- function(model) {
222221
Min = min(x),
223222
Max = max(x),
224223
Proportion_Positive = sum(x >= 0) / length(x),
224+
Proportion_Zero = sum(x == 0) / length(x),
225225
Integer = all(.is_integer(x))
226226
)
227227
}

R/sysdata.rda

-3.06 KB
Binary file not shown.

WIP/generate_distribution.R

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,25 @@ for (di in seq_along(distrs)) {
134134
# x_scaled <- parameters::normalize(x, verbose = FALSE)
135135

136136
if (length(x) >= 10) {
137+
mode <- tryCatch(
138+
bayestestR::map_estimate(x, bw = "nrd0"),
139+
error = function(e) NULL
140+
)
141+
if (is.null(mode)) {
142+
mode <- tryCatch(
143+
bayestestR::map_estimate(x, bw = "kernel"),
144+
error = function(e) NULL
145+
)
146+
}
147+
if (is.null(mode)) {
148+
mode <- datawizard::distribution_mode(x)
149+
}
137150
# Extract features
138151
data <- data.frame(
139152
"SD" = sd(x),
140153
"MAD" = mad(x, constant = 1),
141154
"Mean_Median_Distance" = mean(x) - median(x),
142-
"Mean_Mode_Distance" = mean(x) - as.numeric(bayestestR::map_estimate(x, bw = "nrd0")),
155+
"Mean_Mode_Distance" = mean(x) - as.numeric(mode),
143156
"SD_MAD_Distance" = sd(x) - mad(x, constant = 1),
144157
"Var_Mean_Distance" = var(x) - mean(x),
145158
"Range_SD" = diff(range(x)) / sd(x),
@@ -152,8 +165,8 @@ for (di in seq_along(distrs)) {
152165
"Min" = min(x),
153166
"Max" = max(x),
154167
"Proportion_Positive" = sum(x >= 0) / length(x),
155-
"Integer" = all(.is.integer(x))
156-
# "Proportion_Zero" = sum(x == 0) / length(x)
168+
"Integer" = all(.is.integer(x)),
169+
"Proportion_Zero" = sum(x == 0) / length(x)
157170
# "Proportion_Minimum" = sum(x == min(x)) / length(x),
158171
# "Proportion_Maximum" = sum(x == max(x)) / length(x)
159172
)

man/check_distribution.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)