Skip to content

Commit

Permalink
update model
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed May 5, 2024
1 parent f2da2ad commit 0fb5145
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.11.0.6
Version: 0.11.0.7
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
12 changes: 6 additions & 6 deletions R/check_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ NULL
#' This function uses an internal random forest model to classify the
#' distribution from a model-family. Currently, following distributions are
#' trained (i.e. results of `check_distribution()` may be one of the
#' following): `"bernoulli"`, `"beta"`, `"beta-binomial"`,
#' `"binomial"`, `"chi"`, `"exponential"`, `"F"`,
#' `"gamma"`, `"lognormal"`, `"normal"`, `"negative
#' binomial"`, `"negative binomial (zero-inflated)"`, `"pareto"`,
#' `"poisson"`, `"poisson (zero-inflated)"`, `"uniform"` and
#' `"weibull"`.
#' following): `"bernoulli"`, `"beta"`, `"beta-binomial"`, `"binomial"`,
#' `"cauchy"`, `"chi"`, `"exponential"`, `"F"`, `"gamma"`, `"half-cauchy"`,
#' `"inverse-gamma"`, `"lognormal"`, `"normal"`, `"negative binomial"`,
#' `"negative binomial (zero-inflated)"`, `"pareto"`, `"poisson"`,
#' `"poisson (zero-inflated)"`, `"tweedie"`, `"uniform"` and `"weibull"`.
#' \cr \cr
#' Note the similarity between certain distributions according to shape, skewness,
#' etc. Thus, the predicted distribution may not be perfectly representing the
Expand Down Expand Up @@ -222,6 +221,7 @@ check_distribution.numeric <- function(model) {
Min = min(x),
Max = max(x),
Proportion_Positive = sum(x >= 0) / length(x),
Proportion_Zero = sum(x == 0) / length(x),
Integer = all(.is_integer(x))
)
}
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
19 changes: 16 additions & 3 deletions WIP/generate_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,25 @@ for (di in seq_along(distrs)) {
# x_scaled <- parameters::normalize(x, verbose = FALSE)

if (length(x) >= 10) {
mode <- tryCatch(
bayestestR::map_estimate(x, bw = "nrd0"),
error = function(e) NULL
)
if (is.null(mode)) {
mode <- tryCatch(
bayestestR::map_estimate(x, bw = "kernel"),
error = function(e) NULL
)
}
if (is.null(mode)) {
mode <- datawizard::distribution_mode(x)
}
# Extract features
data <- data.frame(
"SD" = sd(x),
"MAD" = mad(x, constant = 1),
"Mean_Median_Distance" = mean(x) - median(x),
"Mean_Mode_Distance" = mean(x) - as.numeric(bayestestR::map_estimate(x, bw = "nrd0")),
"Mean_Mode_Distance" = mean(x) - as.numeric(mode),
"SD_MAD_Distance" = sd(x) - mad(x, constant = 1),
"Var_Mean_Distance" = var(x) - mean(x),
"Range_SD" = diff(range(x)) / sd(x),
Expand All @@ -152,8 +165,8 @@ for (di in seq_along(distrs)) {
"Min" = min(x),
"Max" = max(x),
"Proportion_Positive" = sum(x >= 0) / length(x),
"Integer" = all(.is.integer(x))
# "Proportion_Zero" = sum(x == 0) / length(x)
"Integer" = all(.is.integer(x)),
"Proportion_Zero" = sum(x == 0) / length(x)
# "Proportion_Minimum" = sum(x == min(x)) / length(x),
# "Proportion_Maximum" = sum(x == max(x)) / length(x)
)
Expand Down
10 changes: 5 additions & 5 deletions man/check_distribution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0fb5145

Please sign in to comment.