Skip to content

Commit

Permalink
Show message regarding CVI inversion (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
asardaes committed Sep 24, 2022
1 parent ce35d84 commit 3078a23
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 5.5.11
* Documentation update (#61).
* Specify minimum supported version of package `Matrix`.

## Version 5.5.10
* Enhanced `compare_clusterings` to allow complex parameters in lists (#59).

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: Time series clustering along with optimized techniques related
All included distance functions have custom loops optimized for the
calculation of cross-distance matrices, including parallelization support.
Several cluster validity indices are included.
Version: 5.5.10.9000
Version: 5.5.11
Depends:
R (>= 3.3.0),
methods,
Expand Down
16 changes: 12 additions & 4 deletions R/CLUSTERING-cvi-evaluators.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#' for picking. They always assume that no errors occurred.
#'
#' The scoring function takes the CVIs that are to be minimized and "inverts" them by taking their
#' reciprocal so that maximization can be considered. Its ellipsis (`...`) is passed to [cvi()].
#' reciprocal so that maximization can be considered uniformly for the purpose of majority voting.
#' Its ellipsis (`...`) is passed to [cvi()].
#'
#' The picking function returns the best configuration if `return.objects` is `FALSE`, or a list
#' with the chosen [TSClusters-class] object and the corresponding configuration otherwise.
Expand Down Expand Up @@ -61,16 +62,23 @@ cvi_evaluators <- function(type = "valid", fuzzy = FALSE, ground.truth = NULL) {
stop("The ground.truth is needed for external CVIs.")
}

internal <- intersect(type, internal)
external <- intersect(type, external)

if (any(c(internal, external) %in% minimize)) {
message("Some of the chosen CVIs are to be minized,",
" but their values will be inverted by the scoring function.",
" See this function's documentation for more details,",
" and use suppressMessages to avoid this message.")
}

majority <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}

score <- function(objs, ...) {
do.call(rbind, lapply(objs, function(obj) {
internal <- intersect(type, internal)
external <- intersect(type, external)

if (length(internal) > 0L)
cvis <- cvi(a = obj, type = internal, ...)
else
Expand Down
2 changes: 1 addition & 1 deletion R/GENERICS-cvi.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#' additional distance calculations when being computed, which can be very considerable if using DTW
#' or GAK.
#'
#' @return The chosen CVIs
#' @return The chosen CVIs.
#'
#' @section External CVIs:
#'
Expand Down
3 changes: 2 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

## Update to version
## Update to version 5.5.11
Specify minimum Matrix version as suggested by their maintainers, and documentation updates.

## Test environments
* Local GNU/Linux, R release
Expand Down
5 changes: 3 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
Full changelog available at \url{https://github.com/asardaes/dtwclust/blob/master/CHANGELOG.md}
}

\section{Changes in version 5.5.10.9000}{
\section{Changes in version 5.5.11}{
\itemize{
\item TBD.
\item Documentation update.
\item Specify minimum supported version of package \pkg{Matrix}.
}
}
2 changes: 1 addition & 1 deletion man/cvi.Rd

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

3 changes: 2 additions & 1 deletion man/cvi_evaluators.Rd

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

0 comments on commit 3078a23

Please sign in to comment.