R/utilities.R
.dist_from_vector untypeable
unbound variable (line 11)
unbound: sqrt — a name the prelude does not declare
error detail
name: sqrt
timing: 0.132 s
source
.dist_from_vector <-
function(x, n = NULL, labels = NULL)
{
## This might be useful as as.dist.vector, perhaps without the extra
## argument n then which we only have for minimal performance gains.
if(is.null(n))
n <- as.integer((sqrt(1 + 8 * length(x)) + 1) / 2)
attr(x, "Size") <- n
if(!is.null(labels))
attr(x, "Labels") <- labels
class(x) <- "dist"
x
}
R/utilities.R:5
.one_entry_per_column untypeable
untypeable application of base::seq_len (line 35)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.020 s
source
.one_entry_per_column <-
function(x, j)
{
## For a matrix x and a vector of column indices j_1, ..., j_n where
## n is the number of rows of x, get x[1,j_1], ..., x[n,j_n].
## <NOTE>
## This used to have
## if(!is.matrix(x))
## stop("Argument 'x' must be a matrix.")
## but that will fail for sparse matrix classes.
## So let us hope for the best ...
## </NOTE>
x[cbind(seq_len(nrow(x)), j)]
}
R/utilities.R:21
.one_entry_per_column<- untypeable
untypeable application of base::seq_len (line 49)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.037 s
source
".one_entry_per_column<-" <-
function(x, j, value)
{
## <NOTE>
## This used to have
## if(!is.matrix(x))
## stop("Argument 'x' must be a matrix.")
## but that will fail for sparse matrix classes.
## So let us hope for the best ...
## </NOTE>
x[cbind(seq_len(nrow(x)), j)] <- value
x
}
R/utilities.R:38
.symmetric_matrix_from_veclh untypeable
unbound variable (line 61)
unbound: sqrt — a name the prelude does not declare
error detail
name: sqrt
timing: 0.106 s
source
.symmetric_matrix_from_veclh <-
function(x, n = NULL)
{
## In essence the same as as.matrix.dist, but without handling the
## additional attributes that dist objects might have.
if(is.null(n))
n <- as.integer((sqrt(1 + 8 * length(x)) + 1) / 2)
M <- matrix(0, n, n)
M[row(M) > col(M)] <- x
M + t(M)
}
R/utilities.R:55
.weighted_mean_of_object_dissimilarities untypeabletyped
unbound variable (line 73)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: typed
((x: any, w: null?) -> any)<>
timing: 0.878 s
source
.weighted_mean_of_object_dissimilarities <-
function(x, w = NULL)
{
w <- if(is.null(w)) {
rep.int(1, length(x))
} else {
rep_len(w, length(x))
}
## (Need the latter because we want w / sum(w) ...)
dissimilarities <- lapply(x, cl_object_dissimilarities)
m <- rowSums(mapply(`*`, dissimilarities, w / sum(w)))
labels <- attr(dissimilarities[[1L]], "Labels")
.dist_from_vector(m, labels = labels)
}
R/utilities.R:69
.weighted_sum_of_matrices untypeable
unbound variable (line 93)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
timing: 0.262 s
source
.weighted_sum_of_matrices <-
function(x, w = NULL, nr = NULL)
{
## Quite often we need to compute weighted sums \sum_b w_b X_b of
## conforming matrices \{ X_b \}. If x is a list containing the
## matrices and w the vector of weights, it seems that one
## reasonably efficient way of doing this is the following.
if(is.null(w)) w <- rep.int(1, length(x))
if(is.null(nr)) nr <- NROW(x[[1L]])
matrix(rowSums(mapply(`*`, x, w)), nr)
}
R/utilities.R:86
.weighted_sum_of_vectors untypeable
unbound variable (line 104)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
timing: 0.140 s
source
.weighted_sum_of_vectors <-
function(x, w = NULL)
{
## See above.
if(is.null(w)) w <- rep.int(1, length(x))
rowSums(mapply(`*`, x, w))
}
R/utilities.R:100
.make_container untypeabletyped
unbound variable (line 116)
unbound: unique — a name the prelude does not declare
error detail
name: unique
gradual mode: typed
((x: any, classes: any, properties: any?) -> any)<>
timing: 0.014 s
source
.make_container <-
function(x, classes, properties = NULL)
{
out <- list(.Data = x, .Meta = properties)
class(out) <- unique(classes)
out
}
R/utilities.R:112
.get_representation typed accepts outside
∀'a. ((x: { .Data: 'a, any }) -> 'a)<>
timing: 0.021 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { .Data: 'I6523, any }) -> 'I6523)<>
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:env | .get_representation("x" = new.env()) | null |
| x | kind:lang | .get_representation("x" = quote(f(x))) | null |
source
.get_representation <-
function(x)
x$.Data
R/utilities.R:122
.get_properties typed accepts outside
∀'a. ((x: { .Meta: 'a, any }) -> 'a)<>
timing: 0.022 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { .Meta: 'I6530, any }) -> 'I6530)<>
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | kind:null | .get_properties(NULL) | null |
source
.get_properties <-
function(x)
x$.Meta
R/utilities.R:125
.get_property typed any: which fuzz ok
∀'a,'b,'c. (((x: { .Meta: <@"[[", ...>, any }, which: any) -> any) & ((x: { .Meta: v('c)<~@"[[", ...>, any }, which: CHR | DBL | INT | LGL | RAW) -> v1('c)<>) & ((x: { .Meta: { 'a }<~@"[[", ...>, any }, which: CHR) -> null | 'a) & ((x: { .Meta: { 'b }<~@"[[", ...>, any }, which: dbl) -> 'b))<>
timing: 0.379 s
fuzzing: 18 inside (3 ok, 15 error type) · 8 outside (8 rejected)
type drawn from: (((x: { .Meta: <@"[[", ...>, any }, which: any) -> any) & ((x: { .Meta: v('I6554)<~@"[[", ...>, any }, which: CHR | DBL | INT | LGL | RAW) -> v1('I6554)<>) & ((x: { .Meta: { 'I6540 }<~@"[[", ...>, any }, which: CHR) -> null | 'I6540) & ((x: { .Meta: { 'I6541 }<~@"[[", ...>, any }, which: dbl) -> 'I6541))<>
Other calls inside the domain
| call | verdict | error |
|---|
| .get_property(list(".Meta" = "a"), "which" = NA_character_) | error_type | base::[[: subscript out of bounds |
| .get_property(list(".Meta" = list(), NULL), FALSE) | error_type | base::[[: attempt to select less than one element in integerOneIndex |
| .get_property(list(".Meta" = logical(0), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })), "which" = as.raw(c(255))) | error_type | base::[[: invalid subscript type 'raw' |
| .get_property(list(".Meta" = list(1L, integer(0)), as.name("x"), function(...) function(...) NULL), c("NA", "a")) | error_type | base::[[: no such index at level 1
|
| .get_property("x" = list(".Meta" = list(c("NA", "a", "NA", "NA", "x y"))), "which" = as.raw(c(0, 255, 0, 0, 255))) | error_type | base::[[: invalid subscript type 'raw' |
| .get_property(list(".Meta" = NA_complex_, new.env()), "é") | error_type | base::[[: subscript out of bounds |
and 9 more
source
.get_property <-
function(x, which)
x$.Meta[[which]]
R/utilities.R:128
.has_property typed accepts outside
(((x: { .Meta: any, any }, which: vec | null) -> LGL<>)&((x: { .Meta: any, any }, which: vec1) -> LGL1<>))<>
timing: 0.082 s
fuzzing: 8 inside (8 ok) · 8 outside (5 rejected, 3 accepted)
Accepted outside the domain which: 3
| parameter | change | call | returned |
|---|
| which | wrap | .has_property(list(".Meta" = new.env(), new.env(), list()), list(NULL)) | ff<> with { } |
| which | wrap | .has_property(list(".Meta" = function(...) NULL, quote(f(x)), list(as.name("x"))), list("NA")) | ff<> with { } |
| which | wrap | .has_property(list(".Meta" = new.env(), quote(f(x))), list(FALSE)) | ff<> with { } |
source
.has_property <-
function(x, which)
which %in% names(x$.Meta)
R/utilities.R:131
.get_property_from_object_or_representation untypeable
untypeable projection (line 141)
error detail
argument: any
argument may be: new.env()
timing: 4.71 s
source
.get_property_from_object_or_representation <-
function(x, which, getter)
{
if(.has_property(x, which))
.get_property(x, which)
else {
if(missing(getter)) getter <- get(which)
getter(.get_representation(x))
}
}
R/utilities.R:134
.print_container untypeabletyped
unbound variable (line 150)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, cls: any, ...: any) -> 'a)<>
timing: 0.011 s
source
.print_container <-
function(x, cls, ...)
{
writeLines(gettextf("An object of virtual class '%s', with representation:\n",
cls))
print(.get_representation(x), ...)
invisible(x)
}
R/utilities.R:147
weighted_median untypeable
unbound variable (line 161)
unbound: rep_len — a name the prelude does not declare
error detail
name: rep_len
timing: 0.138 s
source
weighted_median <-
function(x, w = 1, na.rm = FALSE)
{
w <- rep_len(w, length(x))
if(na.rm && any(ind <- is.na(x))) {
x <- x[!ind]
w <- w[!ind]
}
if(any(is.na(x)) || !length(x))
return(NA)
w <- w / sum(w)
ind <- order(x)
x <- x[ind]
w <- w[ind]
x[which.min(x * (cumsum(w) - 0.5) - cumsum(w * x))]
}
R/utilities.R:158
R/membership.R
cl_membership untypeabletyped
unbound variable (line 25)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.008 s
source
cl_membership <-
function(x, k = n_of_classes(x))
{
if(k < n_of_classes(x))
stop("k cannot be less than the number of classes in x.")
UseMethod("cl_membership")
}
R/membership.R:24
.make_cl_membership untypeabletyped
unbound variable (line 109)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((x: any, n_of_classes: any, is_cl_hard_partition: any, meta: any?) -> any)<>
timing: 0.018 s
source
.make_cl_membership <-
function(x, n_of_classes, is_cl_hard_partition, meta = NULL)
{
attr(x, "n_of_classes") <- n_of_classes
attr(x, "is_cl_hard_partition") <- is_cl_hard_partition
attr(x, "meta") <- meta
class(x) <- "cl_membership"
x
}
R/membership.R:106
.cl_membership_from_class_ids untypeable
untypeable assignment (line 125)
error detail
variable: k
expected: null
given: INT1<>
expression may be: NA_integer_
timing: 0.110 s
source
.cl_membership_from_class_ids <-
function(x, k = NULL, meta = NULL)
{
x <- factor(x)
n_of_objects <- length(x)
n_of_classes <- nlevels(x)
if(is.null(k))
k <- n_of_classes
else if(k < n_of_classes)
stop("k cannot be less than the number of classes in x.")
## <TODO>
## Should really use a sparse encoding of this ...
M <- matrix(0, n_of_objects, k)
## (Could also use .one_entry_per_column(M, as.numeric(x)) <- 1 for
## the time being.)
M[cbind(seq_len(n_of_objects), as.numeric(x))] <- 1
## But note that we also need to handle NAs ...
M[is.na(x), ] <- NA
## </TODO>
if(nlevels(x) == k)
colnames(M) <- levels(x)
if(!is.null(nm <- names(x)))
rownames(M) <- nm
.make_cl_membership(M, n_of_classes, TRUE, meta)
}
R/membership.R:118
cl_membership.default untypeabletyped
unbound variable (line 34)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.007 s
source
cl_membership.default <-
function(x, k = n_of_classes(x))
.cl_membership_from_class_ids(cl_class_ids(x), k)
R/membership.R:33
cl_membership.kmeans untypeabletyped
unbound variable (line 38)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.kmeans <- cl_membership.default
R/membership.R:38
.cl_membership_from_memberships untypeabletyped
unbound variable (line 155)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: any, k: null?, meta: any?) -> any)<>
timing: 0.057 s
source
.cl_membership_from_memberships <-
function(x, k = NULL, meta = NULL)
{
## <NOTE>
## Dropping and re-filling of ## zero columns in case k is given may
## seem unnecessary, but really canonicalizes by moving zero columns
## last ...
## </NOTE>
x <- x[ , colSums(x, na.rm = TRUE) > 0, drop = FALSE]
n_of_classes <- ncol(x)
if(!is.null(k)) {
if(k < n_of_classes)
stop("k cannot be less than the number of classes in x.")
if(k > n_of_classes) {
## Fill up with zero columns.
x <- cbind(x, matrix(0, nrow(x), k - n_of_classes))
## Handle NAs if necessary.
x[apply(is.na(x), 1, any), ] <- NA
}
}
.make_cl_membership(x, n_of_classes,
all(rowSums(x == 1, na.rm = TRUE) > 0),
meta)
}
R/membership.R:146
cl_membership.fanny untypeabletyped
unbound variable (line 43)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.006 s
source
cl_membership.fanny <-
function(x, k = n_of_classes(x))
.cl_membership_from_memberships(x$membership, k)
R/membership.R:42
cl_membership.partition untypeabletyped
unbound variable (line 45)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.partition <- cl_membership.default
R/membership.R:45
cl_membership.cclust untypeabletyped
unbound variable (line 48)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.cclust <- cl_membership.default
R/membership.R:48
cl_membership.fclust untypeabletyped
unbound variable (line 51)
unbound: cl_membership.fanny — one of the package’s own names, itself untyped
error detail
name: cl_membership.fanny
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.000 s
source
cl_membership.fclust <- cl_membership.fanny
R/membership.R:51
cl_membership.cshell untypeabletyped
unbound variable (line 53)
unbound: cl_membership.fanny — one of the package’s own names, itself untyped
error detail
name: cl_membership.fanny
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.000 s
source
cl_membership.cshell <- cl_membership.fanny
R/membership.R:53
cl_membership.bclust untypeabletyped
unbound variable (line 55)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.bclust <- cl_membership.default
R/membership.R:55
cl_membership.flexmix untypeabletyped
unbound variable (line 64)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.005 s
source
cl_membership.flexmix <-
function(x, k = n_of_classes(x))
.cl_membership_from_memberships(modeltools::posterior(x), k)
R/membership.R:63
cl_membership.Mclust untypeabletyped
unbound variable (line 69)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { z: any, any }, k: null?) -> any)<>
timing: 0.005 s
source
cl_membership.Mclust <-
function(x, k = n_of_classes(x))
.cl_membership_from_memberships(x$z, k)
R/membership.R:68
cl_membership.cl_membership untypeabletyped
unbound variable (line 74)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: null?) -> any)<>
timing: 0.005 s
source
cl_membership.cl_membership <-
function(x, k = n_of_classes(x))
.cl_membership_from_memberships(x, k)
R/membership.R:73
cl_membership.pclust untypeabletyped
unbound variable (line 81)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { membership: any, cluster: any, any }, k: any?) -> any)<>
timing: 0.014 s
source
cl_membership.pclust <-
function(x, k = n_of_classes(x))
{
## We should really have a suitable "sparse matrix" class for
## representing the memberships of hard partitions. In case we
## decide not to fill the membership "slot" for such:
if(is.null(m <- x$membership))
.cl_membership_from_class_ids(x$cluster, k)
else
.cl_membership_from_memberships(m, k)
}
R/membership.R:80
cl_membership.cl_partition untypeabletyped
unbound variable (line 94)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { .Data: any, any }, k: any?) -> any)<>
timing: 0.005 s
source
cl_membership.cl_partition <-
function(x, k = n_of_classes(x))
cl_membership(.get_representation(x), k)
R/membership.R:93
cl_membership.movMF untypeabletyped
unbound variable (line 99)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { P: any, any }, k: null?) -> any)<>
timing: 0.006 s
source
cl_membership.movMF <-
function(x, k = n_of_classes(x))
.cl_membership_from_memberships(x$P, k)
R/membership.R:98
as.cl_membership untypeabletyped
unbound variable (line 176)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_membership <-
function(x)
UseMethod("as.cl_membership")
R/membership.R:174
as.cl_membership.default untypeabletyped
unbound variable (line 182)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: any) -> any)<>
timing: 0.018 s
source
as.cl_membership.default <-
function(x)
{
if(inherits(x, "cl_membership"))
x
else if(is.atomic(x))
.cl_membership_from_class_ids(x)
else
cl_membership(x)
}
R/membership.R:177
as.cl_membership.matrix untypeabletyped
unbound variable (line 189)
unbound: .cl_membership_from_memberships — one of the package’s own names, itself untyped
error detail
name: .cl_membership_from_memberships
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_membership.matrix <-
function(x)
.cl_membership_from_memberships(x)
R/membership.R:187
.memberships_from_cross_dissimilarities untypeable
untypeable application of base::matrix (line 209)
error detail
argument: @(0.<>, INT1<> | null, INT1<> | null)
failing call: base::matrix(0, NA_integer_, NULL)
timing: 1.02 s
source
.memberships_from_cross_dissimilarities <-
function(d, power = 2)
{
## For a given matrix of cross-dissimilarities [d_{bj}], return a
## matrix [u_{bj}] such that \sum_{b,j} u_{bj}^p d_{bj}^q => min!
## under the constraint that u is a stochastic matrix.
## If only one power is given, it is taken as p, with q as 1.
## <NOTE>
## This returns a plain matrix of membership values and not a
## cl_membership object (so that it does not deal with possibly
## dropping or re-introducing unused classes).
## </NOTE>
exponent <- if(length(power) == 1L)
1 / (1 - power)
else
power[2L] / (1 - power[1L])
u <- matrix(0, nrow(d), ncol(d))
zero_incidences <- !(d > 0)
n_of_zeroes <- rowSums(zero_incidences)
if(any(ind <- (n_of_zeroes > 0)))
u[ind, ] <-
zero_incidences[ind, , drop = FALSE] / n_of_zeroes[ind]
if(any(!ind)) {
## Compute d_{bj}^e / \sum_k d_{bk}^e without overflow from very
## small d_{bj} values.
d <- exponent * log(d[!ind, , drop = FALSE])
d <- exp(d - d[cbind(seq_len(nrow(d)), max.col(d))])
u[!ind, ] <- d / rowSums(d)
}
u
}
R/membership.R:193
print.cl_membership untypeabletyped
unbound variable (line 230)
unbound: writeLines — a name the prelude does not declare
error detail
name: writeLines
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
print.cl_membership <-
function(x, ...)
{
writeLines("Memberships:")
print(matrix(as.vector(x), nrow = nrow(x), dimnames = dimnames(x)),
...)
invisible(x)
}
R/membership.R:227
.has_object_memberships untypeabletyped
unbound variable (line 246)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
gradual mode: typed
((x: any) -> ff<> | tt<>)<>
timing: 0.015 s
source
.has_object_memberships <-
function(x)
(is.cl_partition(x)
|| inherits(x, "cl_membership")
|| inherits(x, "cl_class_ids"))
R/membership.R:244
.stochastify untypeabletyped
unbound variable (line 256)
unbound: pmax — a name the prelude does not declare
error detail
name: pmax
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
.stochastify <-
function(x)
{
## Try to ensure that a stochastic matrix is returned.
x <- pmax(x, 0)
x / rowSums(x)
}
R/membership.R:252
R/registration.R
.make_db_key typed any: name, type fuzz ok
(((name: any, type: any) -> CHR<>)&((name: vec1, type: vec1) -> CHR1<>))<>
timing: 0.055 s
fuzzing: 8 inside (6 ok, 2 error type) · 8 outside (8 rejected)
Other calls inside the domain
| call | verdict | error |
|---|
| .make_db_key("name" = function(...) NULL, "type" = NULL) | error_type | base::paste: cannot coerce type 'closure' to vector of type 'character' |
| .make_db_key(function(...) NULL, "type" = as.name("x")) | error_type | base::paste: cannot coerce type 'closure' to vector of type 'character' |
source
.make_db_key <- function(name, type) paste(type, name, sep = "_")
R/registration.R:9
get_methods_from_db untypeabletyped
unbound variable (line 23)
unbound: objects — a name the prelude does not declare
error detail
name: objects
gradual mode: typed
((db: any, type: vec | null) -> any)<>
timing: 0.046 s
source
get_methods_from_db <- function(db, type) {
type <- match.arg(type, c("partition", "hierarchy"))
pattern <- sprintf("^%s_", type)
sub(pattern, "",
grep(pattern, objects(db), value = TRUE))
}
R/registration.R:18
get_method_from_db untypeabletyped
unbound variable (line 32)
unbound: objects — a name the prelude does not declare
error detail
name: objects
gradual mode: typed
((db: any, type: vec | null, name: vec, msg: any) -> any)<>
timing: 0.062 s
source
get_method_from_db <- function(db, type, name, msg) {
## <NOTE>
## Keep 'msg' here so that gettext()ing could work ...
## </NOTE>
type <- match.arg(type, c("partition", "hierarchy"))
db_keys <- objects(db)
ind <- pmatch(.make_db_key(tolower(name), type), tolower(db_keys))
if(is.na(ind))
stop(msg, call. = FALSE, domain = NA)
db[[db_keys[ind]]]
}
R/registration.R:26
put_method_into_db typed any: name, value fuzz ok
((db: list, type: vec | null, name: any, value: any) | (db: vec, type: vec | null, name: any, value: vec) -> null)<>
timing: 0.323 s
fuzzing: 8 inside (6 error pkg, 2 error type) · 8 outside (8 rejected)
Other calls inside the domain
| call | verdict | error |
|---|
| put_method_into_db(list(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), NULL), "type" = -Inf, "name" = function(...) as.name("x"), "value" = function(...) quote(f(x))) | error_pkg | base::match.arg: 'arg' must be NULL or a character vector |
| put_method_into_db("db" = list(), "type" = c(NA_integer_, NA_integer_), "name" = as.name("x"), "value" = as.name("x")) | error_pkg | base::match.arg: 'arg' must be NULL or a character vector |
| put_method_into_db(list(function(...) quote(f(x)), quote(f(x))), integer(0), NULL, NULL) | error_pkg | base::match.arg: 'arg' must be NULL or a character vector |
| put_method_into_db(list(), c(2L, 42L, -2147483647L, NA_integer_, -1L), new.env(), as.name("x")) | error_pkg | base::match.arg: 'arg' must be NULL or a character vector |
| put_method_into_db(list(c(2L, -2147483647L), function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })), as.raw(c(0)), list(function(...) new.env()), "value" = quote(f(x))) | error_pkg | base::match.arg: 'arg' must be NULL or a character vector |
| put_method_into_db(c(FALSE, TRUE), "type" = NULL, "name" = as.name("x"), "value" = c(42L, 2147483647L, -2147483647L, 2147483647L, 1000000L)) | error_type | base::<-: more elements supplied than there are to replace |
and 2 more
source
put_method_into_db <- function(db, type, name, value) {
type <- match.arg(type, c("partition", "hierarchy"))
db[[.make_db_key(name, type)]] <- value
}
R/registration.R:40
cl_consensus_methods_db typed
env
timing: 0.003 s
source
cl_consensus_methods_db <- new.env()
R/registration.R:47
get_cl_consensus_methods untypeabletyped
unbound variable (line 50)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_consensus_methods <- function(type)
get_methods_from_db(cl_consensus_methods_db, type)
R/registration.R:49
get_cl_consensus_method untypeabletyped
unbound variable (line 53)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.004 s
source
get_cl_consensus_method <- function(name, type) {
get_method_from_db(cl_consensus_methods_db, type, name,
gettextf("Invalid consensus method '%s'.", name))
}
R/registration.R:51
set_cl_consensus_method untypeable
unbound variable (line 65)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.067 s
source
set_cl_consensus_method <-
function(name, type, definition, ...)
{
## Register a @code{type} consensus method called @code{name} with
## definition @code{definition}. Provide more information where
## appropriate, e.g., @code{dissimilarity} d and @code{exponent} e
## for methods minimizing \sum_b d(x_b, x) ^ e.
put_method_into_db(cl_consensus_methods_db, type, name,
.structure(c(list(definition = definition),
list(...)),
class = "cl_consensus_method"))
}
R/registration.R:56
<statement> untypeabletyped
unbound variable (line 71)
unbound: .cl_consensus_partition_DWH — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_DWH
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("DWH", "partition",
.cl_consensus_partition_DWH,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:70
<statement> untypeabletyped
unbound variable (line 75)
unbound: .cl_consensus_partition_soft_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("soft/euclidean", "partition",
.cl_consensus_partition_soft_euclidean,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:74
<statement> untypeabletyped
unbound variable (line 79)
unbound: .cl_consensus_partition_soft_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("SE", "partition",
.cl_consensus_partition_soft_euclidean,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:78
<statement> untypeabletyped
unbound variable (line 83)
unbound: .cl_consensus_partition_hard_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("hard/euclidean", "partition",
.cl_consensus_partition_hard_euclidean,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:82
<statement> untypeabletyped
unbound variable (line 87)
unbound: .cl_consensus_partition_hard_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("HE", "partition",
.cl_consensus_partition_hard_euclidean,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:86
<statement> untypeabletyped
unbound variable (line 91)
unbound: .cl_consensus_partition_soft_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("soft/manhattan", "partition",
.cl_consensus_partition_soft_manhattan,
dissimilarity = "manhattan",
exponent = 1)
R/registration.R:90
<statement> untypeabletyped
unbound variable (line 95)
unbound: .cl_consensus_partition_soft_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("SM", "partition",
.cl_consensus_partition_soft_manhattan,
dissimilarity = "manhattan",
exponent = 1)
R/registration.R:94
<statement> untypeabletyped
unbound variable (line 99)
unbound: .cl_consensus_partition_hard_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("hard/manhattan", "partition",
.cl_consensus_partition_hard_manhattan,
dissimilarity = "manhattan",
exponent = 1)
R/registration.R:98
<statement> untypeabletyped
unbound variable (line 103)
unbound: .cl_consensus_partition_hard_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("HM", "partition",
.cl_consensus_partition_hard_manhattan,
dissimilarity = "manhattan",
exponent = 1)
R/registration.R:102
<statement> untypeabletyped
unbound variable (line 107)
unbound: .cl_consensus_partition_GV1 — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_GV1
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("GV1", "partition",
.cl_consensus_partition_GV1,
dissimilarity = "GV1",
exponent = 2)
R/registration.R:106
<statement> untypeabletyped
unbound variable (line 111)
unbound: .cl_consensus_partition_GV3 — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_GV3
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("GV3", "partition",
.cl_consensus_partition_GV3,
dissimilarity = "comemberships",
exponent = 2)
R/registration.R:110
<statement> untypeabletyped
unbound variable (line 115)
unbound: .cl_consensus_partition_soft_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_symdiff
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("soft/symdiff", "partition",
.cl_consensus_partition_soft_symdiff,
dissimilarity = "symdiff",
exponent = 1)
R/registration.R:114
<statement> untypeabletyped
unbound variable (line 119)
unbound: .cl_consensus_partition_hard_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_symdiff
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("hard/symdiff", "partition",
.cl_consensus_partition_hard_symdiff,
dissimilarity = "symdiff",
exponent = 1)
R/registration.R:118
<statement> untypeabletyped
unbound variable (line 124)
unbound: .cl_consensus_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_cophenetic
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("cophenetic", "hierarchy",
.cl_consensus_hierarchy_cophenetic,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:123
<statement> untypeabletyped
unbound variable (line 128)
unbound: .cl_consensus_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_cophenetic
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("euclidean", "hierarchy",
.cl_consensus_hierarchy_cophenetic,
dissimilarity = "euclidean",
exponent = 2)
R/registration.R:127
<statement> untypeabletyped
unbound variable (line 132)
unbound: .cl_consensus_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("manhattan", "hierarchy",
.cl_consensus_hierarchy_manhattan,
dissimilarity = "manhattan",
exponent = 1)
R/registration.R:131
<statement> untypeabletyped
unbound variable (line 136)
unbound: .cl_consensus_hierarchy_majority — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_majority
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("majority", "hierarchy",
.cl_consensus_hierarchy_majority,
dissimilarity = "symdiff",
exponent = 1)
R/registration.R:135
cl_dissimilarity_methods_db typed
env
timing: 0.003 s
source
cl_dissimilarity_methods_db <- new.env()
R/registration.R:142
get_cl_dissimilarity_methods untypeabletyped
unbound variable (line 145)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_dissimilarity_methods <- function(type)
get_methods_from_db(cl_dissimilarity_methods_db, type)
R/registration.R:144
get_cl_dissimilarity_method untypeabletyped
unbound variable (line 148)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.005 s
source
get_cl_dissimilarity_method <- function(name, type)
get_method_from_db(cl_dissimilarity_methods_db, type, name,
gettextf("Invalid dissimilarity method '%s'.",
name))
R/registration.R:146
set_cl_dissimilarity_method untypeable
unbound variable (line 153)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.102 s
source
set_cl_dissimilarity_method <-
function(name, type, definition, description, ...)
put_method_into_db(cl_dissimilarity_methods_db, type, name,
.structure(c(list(definition = definition,
description = description),
list(...)),
class = "cl_dissimilarity_method"))
R/registration.R:150
<statement> untypeabletyped
unbound variable (line 159)
unbound: .cl_dissimilarity_partition_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("euclidean", "partition",
.cl_dissimilarity_partition_euclidean,
"minimal Euclidean membership distance")
R/registration.R:158
<statement> untypeabletyped
unbound variable (line 162)
unbound: .cl_dissimilarity_partition_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_manhattan
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("manhattan", "partition",
.cl_dissimilarity_partition_manhattan,
"minimal Manhattan membership distance")
R/registration.R:161
<statement> untypeabletyped
unbound variable (line 165)
unbound: .cl_dissimilarity_partition_comemberships — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_comemberships
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("comemberships", "partition",
.cl_dissimilarity_partition_comemberships,
"Euclidean comembership distance")
R/registration.R:164
<statement> untypeabletyped
unbound variable (line 168)
unbound: .cl_dissimilarity_partition_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_symdiff
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("symdiff", "partition",
.cl_dissimilarity_partition_symdiff,
"symmetric difference distance")
R/registration.R:167
<statement> untypeabletyped
unbound variable (line 171)
unbound: .cl_dissimilarity_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Rand
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Rand", "partition",
.cl_dissimilarity_partition_Rand,
"Rand distance")
R/registration.R:170
<statement> untypeabletyped
unbound variable (line 174)
unbound: .cl_dissimilarity_partition_GV1 — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_GV1
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("GV1", "partition",
.cl_dissimilarity_partition_GV1,
"Gordon-Vichi Delta_1 dissimilarity")
R/registration.R:173
<statement> untypeabletyped
unbound variable (line 177)
unbound: .cl_dissimilarity_partition_BA_A — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_A
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("BA/A", "partition",
.cl_dissimilarity_partition_BA_A,
"Boorman/Arabie minimum element moves distance")
R/registration.R:176
<statement> untypeabletyped
unbound variable (line 180)
unbound: .cl_dissimilarity_partition_BA_C — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_C
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/C", "partition",
.cl_dissimilarity_partition_BA_C,
"Boorman/Arabie minimum lattice moves distance")
R/registration.R:179
<statement> untypeabletyped
unbound variable (line 183)
unbound: .cl_dissimilarity_partition_BA_D — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_D
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/D", "partition",
.cl_dissimilarity_partition_BA_D,
"Boorman/Arabie pair-bonds distance")
R/registration.R:182
<statement> untypeabletyped
unbound variable (line 186)
unbound: .cl_dissimilarity_partition_BA_E — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_E
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/E", "partition",
.cl_dissimilarity_partition_BA_E,
"Boorman/Arabie normalized information distance")
R/registration.R:185
<statement> untypeabletyped
unbound variable (line 189)
unbound: .cl_dissimilarity_partition_VI — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_VI
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("VI", "partition",
.cl_dissimilarity_partition_VI,
"Variation of information")
R/registration.R:188
<statement> untypeabletyped
unbound variable (line 192)
unbound: .cl_dissimilarity_partition_Mallows — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Mallows
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Mallows", "partition",
.cl_dissimilarity_partition_Mallows,
"Mallows dissimilarity")
R/registration.R:191
<statement> untypeabletyped
unbound variable (line 195)
unbound: .cl_dissimilarity_partition_CSSD — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_CSSD
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("CSSD", "partition",
.cl_dissimilarity_partition_CSSD,
"Cluster Similarity Sensitive Distance")
R/registration.R:194
<statement> untypeabletyped
unbound variable (line 199)
unbound: .cl_dissimilarity_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("euclidean", "hierarchy",
.cl_dissimilarity_hierarchy_euclidean,
"Euclidean ultrametric distance")
R/registration.R:198
<statement> untypeabletyped
unbound variable (line 202)
unbound: .cl_dissimilarity_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("manhattan", "hierarchy",
.cl_dissimilarity_hierarchy_manhattan,
"Manhattan ultrametric distance")
R/registration.R:201
<statement> untypeabletyped
unbound variable (line 205)
unbound: .cl_dissimilarity_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_cophenetic
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("cophenetic", "hierarchy",
.cl_dissimilarity_hierarchy_cophenetic,
"cophenetic correlations")
R/registration.R:204
<statement> untypeabletyped
unbound variable (line 208)
unbound: .cl_dissimilarity_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_gamma
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("gamma", "hierarchy",
.cl_dissimilarity_hierarchy_gamma,
"rate of inversions")
R/registration.R:207
<statement> untypeabletyped
unbound variable (line 211)
unbound: .cl_dissimilarity_hierarchy_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_symdiff
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("symdiff", "hierarchy",
.cl_dissimilarity_hierarchy_symdiff,
"symmetric difference distance")
R/registration.R:210
<statement> untypeabletyped
unbound variable (line 214)
unbound: .cl_dissimilarity_hierarchy_Chebyshev — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_Chebyshev
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Chebyshev", "hierarchy",
.cl_dissimilarity_hierarchy_Chebyshev,
"Chebyshev distance")
R/registration.R:213
<statement> untypeabletyped
unbound variable (line 217)
unbound: .cl_dissimilarity_hierarchy_Lyapunov — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_Lyapunov
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Lyapunov", "hierarchy",
.cl_dissimilarity_hierarchy_Lyapunov,
"Lyapunov distance")
R/registration.R:216
<statement> untypeabletyped
unbound variable (line 220)
unbound: .cl_dissimilarity_hierarchy_BO — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_BO
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("BO", "hierarchy",
.cl_dissimilarity_hierarchy_BO,
"Boorman/Olivier m_delta tree distance")
R/registration.R:219
<statement> untypeabletyped
unbound variable (line 223)
unbound: .cl_dissimilarity_hierarchy_spectral — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_spectral
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("spectral", "hierarchy",
.cl_dissimilarity_hierarchy_spectral,
"spectral ultrametric distance")
R/registration.R:222
cl_agreement_methods_db typed
env
timing: 0.003 s
source
cl_agreement_methods_db <- new.env()
R/registration.R:228
get_cl_agreement_methods untypeabletyped
unbound variable (line 231)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_agreement_methods <-
function(type)
get_methods_from_db(cl_agreement_methods_db, type)
R/registration.R:229
get_cl_agreement_method untypeabletyped
unbound variable (line 235)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.005 s
source
get_cl_agreement_method <-
function(name, type)
get_method_from_db(cl_agreement_methods_db, type, name,
gettextf("Invalid agreement method '%s'.",
name))
R/registration.R:232
set_cl_agreement_method untypeable
unbound variable (line 240)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.101 s
source
set_cl_agreement_method <-
function(name, type, definition, description, ...)
put_method_into_db(cl_agreement_methods_db, type, name,
.structure(c(list(definition = definition,
description = description),
list(...)),
class = "cl_agreement_method"))
R/registration.R:237
<statement> untypeabletyped
unbound variable (line 246)
unbound: .cl_agreement_partition_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("euclidean", "partition",
.cl_agreement_partition_euclidean,
"minimal euclidean membership distance")
R/registration.R:245
<statement> untypeabletyped
unbound variable (line 249)
unbound: .cl_agreement_partition_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("manhattan", "partition",
.cl_agreement_partition_manhattan,
"minimal manhattan membership distance")
R/registration.R:248
<statement> untypeabletyped
unbound variable (line 252)
unbound: .cl_agreement_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Rand
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("Rand", "partition",
.cl_agreement_partition_Rand,
"Rand index")
R/registration.R:251
<statement> untypeabletyped
unbound variable (line 255)
unbound: .cl_agreement_partition_cRand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_cRand
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("cRand", "partition",
.cl_agreement_partition_cRand,
"corrected Rand index")
R/registration.R:254
<statement> untypeabletyped
unbound variable (line 258)
unbound: .cl_agreement_partition_NMI — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_NMI
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("NMI", "partition",
.cl_agreement_partition_NMI,
"normalized mutual information")
R/registration.R:257
<statement> untypeabletyped
unbound variable (line 261)
unbound: .cl_agreement_partition_KP — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_KP
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("KP", "partition",
.cl_agreement_partition_KP,
"Katz-Powell index")
R/registration.R:260
<statement> untypeabletyped
unbound variable (line 264)
unbound: .cl_agreement_partition_angle — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_angle
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("angle", "partition",
.cl_agreement_partition_angle,
"maximal angle between memberships")
R/registration.R:263
<statement> untypeabletyped
unbound variable (line 267)
unbound: .cl_agreement_partition_diag — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_diag
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("diag", "partition",
.cl_agreement_partition_diag,
"maximal co-classification rate")
R/registration.R:266
<statement> untypeabletyped
unbound variable (line 270)
unbound: .cl_agreement_partition_FM — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_FM
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("FM", "partition",
.cl_agreement_partition_FM,
"Fowlkes-Mallows index")
R/registration.R:269
<statement> untypeabletyped
unbound variable (line 273)
unbound: .cl_agreement_partition_Jaccard — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Jaccard
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("Jaccard", "partition",
.cl_agreement_partition_Jaccard,
"Jaccard index")
R/registration.R:272
<statement> untypeabletyped
unbound variable (line 276)
unbound: .cl_agreement_partition_purity — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_purity
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("purity", "partition",
.cl_agreement_partition_purity,
"purity")
R/registration.R:275
<statement> untypeabletyped
unbound variable (line 279)
unbound: .cl_agreement_partition_PS — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_PS
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("PS", "partition",
.cl_agreement_partition_PS,
"Prediction Strength")
R/registration.R:278
<statement> untypeabletyped
unbound variable (line 283)
unbound: .cl_agreement_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("euclidean", "hierarchy",
.cl_agreement_hierarchy_euclidean,
"euclidean ultrametric distance")
R/registration.R:282
<statement> untypeabletyped
unbound variable (line 286)
unbound: .cl_agreement_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("manhattan", "hierarchy",
.cl_agreement_hierarchy_manhattan,
"manhattan ultrametric distance")
R/registration.R:285
<statement> untypeabletyped
unbound variable (line 289)
unbound: .cl_agreement_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_cophenetic
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("cophenetic", "hierarchy",
.cl_agreement_hierarchy_cophenetic,
"cophenetic correlations")
R/registration.R:288
<statement> untypeabletyped
unbound variable (line 292)
unbound: .cl_agreement_hierarchy_angle — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_angle
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("angle", "hierarchy",
.cl_agreement_hierarchy_angle,
"angle between ultrametrics")
R/registration.R:291
<statement> untypeabletyped
unbound variable (line 295)
unbound: .cl_agreement_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_gamma
gradual mode: typed
timing: 0.001 s
source
set_cl_agreement_method("gamma", "hierarchy",
.cl_agreement_hierarchy_gamma,
"rate of inversions")
R/registration.R:294
R/agreement.R
cl_agreement untypeable
unbound variable (line 11)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.161 s
source
cl_agreement <-
function(x, y = NULL, method = "euclidean", ...)
{
## <NOTE>
## This code is repeated from cl_dissimilarity(), mutatis mutandis.
## Not really a big surprise ...
## </NOTE>
x <- as.cl_ensemble(x)
is_partition_ensemble <-
(inherits(x, "cl_partition_ensemble")
|| all(vapply(x, .has_object_memberships, NA)))
## Be nice.
if(is.character(y) || is.function(y)) {
method <- y
y <- NULL
}
if(is.function(method))
method_name <- "user-defined method"
else {
if(!inherits(method, "cl_agreement_method")) {
## Get the method definition and description from the
## registry.
type <- ifelse(is_partition_ensemble,
"partition", "hierarchy")
method <- get_cl_agreement_method(method, type)
}
method_name <- method$description
method <- method$definition
}
if(!is.null(y)) {
y <- as.cl_ensemble(y)
is_partition_ensemble_y <-
(inherits(y, "cl_partition_ensemble")
|| all(vapply(x, .has_object_memberships, NA)))
if(!identical(is_partition_ensemble, is_partition_ensemble_y))
stop("Cannot mix partitions and hierarchies.")
if(n_of_objects(x) != n_of_objects(y))
stop("All clusterings must have the same number of objects.")
## Build a cross-proximity object of cross-agreements.
d <- matrix(0, length(x), length(y))
for(j in seq_along(y))
d[, j] <- sapply(x, method, y[[j]], ...)
dimnames(d) <- list(names(x), names(y))
return(cl_cross_proximity(d, method_name,
class = "cl_cross_agreement"))
}
## Otherwise, build a proximity object of dissimilarities.
n <- length(x)
d <- vector("list", length = n - 1L)
ind <- seq_len(n)
while(length(ind) > 1L) {
j <- ind[1L]
ind <- ind[-1L]
d[[j]] <- sapply(x[ind], method, x[[j]], ...)
}
## <NOTE>
## We assume that self-agreements are always one ...
## </NOTE>
cl_proximity(unlist(d),
method_name,
labels = names(x),
self = rep.int(1, length(x)),
size = n, class = "cl_agreement")
}
R/agreement.R:3
.cl_agreement_partition_euclidean untypeabletyped
unbound variable (line 81)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.009 s
source
.cl_agreement_partition_euclidean <-
function(x, y)
{
## <NOTE>
## Upper bound for maximal dissimilarity, maybe improve eventually.
d_max <- sqrt(2 * n_of_objects(x))
## </NOTE>
1 - .cl_dissimilarity_partition_euclidean(x, y) / d_max
}
R/agreement.R:76
.cl_agreement_partition_manhattan untypeabletyped
unbound variable (line 93)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.010 s
source
.cl_agreement_partition_manhattan <-
function(x, y)
{
## <NOTE>
## Upper bound for maximal dissimilarity, maybe improve eventually.
d_max <- 2 * n_of_objects(x)
## </NOTE>
1 - .cl_dissimilarity_partition_manhattan(x, y) / d_max
}
R/agreement.R:88
.cl_agreement_partition_Rand untypeabletyped
unbound variable (line 103)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.025 s
source
.cl_agreement_partition_Rand <-
function(x, y)
{
n <- n_of_objects(x)
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
x <- table(cl_class_ids(x), cl_class_ids(y))
## <NOTE>
## The number A of concordant pairs is given by
## A = choose(n,2) + \sum_{i,j} x_{ij}^2
## - (1/2) * (\sum_i x_{i.}^2 + \sum_j x_{.j}^2)
## = choose(n,2) + 2 \sum_{i,j} choose(x_{ij},2)
## - (\sum_i choose(x_{i.},2) + \sum_j choose(x_{.j},2)
## with the first version certainly much faster to compute.
## </NOTE>
1 + (sum(x^2) -
(sum(rowSums(x)^2) + sum(colSums(x)^2)) / 2) / choose(n, 2)
}
R/agreement.R:100
.cl_agreement_partition_cRand untypeabletyped
unbound variable (line 126)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.048 s
source
.cl_agreement_partition_cRand <-
function(x, y)
{
if(!is.cl_hard_partition(x) || !is.cl_hard_partition(y))
stop("Can only handle hard partitions.")
n <- n_of_objects(x)
x <- table(cl_class_ids(x), cl_class_ids(y))
## <NOTE>
## The basic formula is
## (Sxy - E) / ((Sx. + S.y) / 2 - E)
## where
## Sxy = \sum_{i,j} choose(x_{ij}, 2)
## Sx. = \sum_i choose(x_{i.}, 2)
## S.y = \sum_j choose(x_{.j}, 2)
## and
## E = Sx. * S.y / choose(n, 2)
## We replace the bincoefs by the corresponding sums of squares,
## getting
## (Txy - F) / ((Tx. + T.y) / 2 - F)
## where
## Txy = \sum_{i,j} x_{ij}^2 - n
## Tx. = \sum_i x_{i.}^2 - n
## T.y = \sum_j x_{.j}^2 - n
## and
## F = Tx. * T.y / (n^2 - n)
## </NOTE>
Txy <- sum(x ^ 2) - n
Tx. <- sum(rowSums(x) ^ 2) - n
T.y <- sum(colSums(x) ^ 2) - n
F <- Tx. * T.y / (n ^ 2 - n)
(Txy - F) / ((Tx. + T.y) / 2 - F)
}
R/agreement.R:123
.cl_agreement_partition_NMI untypeabletyped
unbound variable (line 164)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.056 s
source
.cl_agreement_partition_NMI <-
function(x, y)
{
if(!is.cl_hard_partition(x) || !is.cl_hard_partition(y))
stop("Can only handle hard partitions.")
x <- table(cl_class_ids(x), cl_class_ids(y))
x <- x / sum(x)
m_x <- rowSums(x)
m_y <- colSums(x)
y <- outer(m_x, m_y)
i <- which((x > 0) & (y > 0))
out <- sum(x[i] * log(x[i] / y[i]))
e_x <- sum(m_x * log(ifelse(m_x > 0, m_x, 1)))
e_y <- sum(m_y * log(ifelse(m_y > 0, m_y, 1)))
out / sqrt(e_x * e_y)
}
R/agreement.R:161
.cl_agreement_partition_KP untypeabletyped
unbound variable (line 189)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.035 s
source
.cl_agreement_partition_KP <-
function(x, y)
{
## Agreement measure due to Katz & Powell (1953, Psychometrika), see
## also Messatfa (1992, Journal of Classification).
n <- n_of_objects(x)
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
x <- table(cl_class_ids(x), cl_class_ids(y))
A_xy <- sum(x ^ 2)
A_x. <- sum(rowSums(x) ^ 2)
A_.y <- sum(colSums(x) ^ 2)
(n^2 * A_xy - A_x. * A_.y) /
sqrt(A_x. * (n^2 - A_x.) * A_.y * (n^2 - A_.y))
}
R/agreement.R:183
.cl_agreement_partition_angle untypeabletyped
unbound variable (line 210)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.019 s
source
.cl_agreement_partition_angle <-
function(x, y)
{
## Maximal angle between the matched memberships.
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
## Match classes from conforming memberships.
ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
sum(M_x * M_y[, ind]) / sqrt(sum(M_x ^ 2) * sum(M_y ^ 2))
}
R/agreement.R:205
.cl_agreement_partition_diag untypeabletyped
unbound variable (line 225)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.011 s
source
.cl_agreement_partition_diag <-
function(x, y)
{
## Maximal co-classification rate.
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
## Match classes from conforming memberships.
ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
sum(M_x * M_y[, ind]) / n_of_objects(x)
}
R/agreement.R:220
.cl_agreement_partition_FM untypeabletyped
unbound variable (line 240)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.023 s
source
.cl_agreement_partition_FM <-
function(x, y)
{
## Fowlkes-Mallows index.
n <- n_of_objects(x)
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
x <- table(cl_class_ids(x), cl_class_ids(y))
(sum(x ^ 2) - n) /
sqrt((sum(rowSums(x) ^ 2) - n) * (sum(colSums(x) ^ 2) - n))
}
R/agreement.R:235
.cl_agreement_partition_Jaccard untypeabletyped
unbound variable (line 258)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.022 s
source
.cl_agreement_partition_Jaccard <-
function(x, y)
{
## Jaccard index.
n <- n_of_objects(x)
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
x <- table(cl_class_ids(x), cl_class_ids(y))
Z <- sum(x ^ 2)
(Z - n) / (sum(rowSums(x) ^ 2) + sum(colSums(x) ^ 2) - n - Z)
}
R/agreement.R:253
.cl_agreement_partition_purity untypeabletyped
unbound variable (line 279)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.020 s
source
.cl_agreement_partition_purity <-
function(x, y)
{
## Purity of classes of x with respect to those of y: relative
## fraction of "optimally matched and collapsed" joint class
## frequencies, i.e., \sum_i \max_j c_{ij} / n.
n <- n_of_objects(x)
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
x <- table(cl_class_ids(x), cl_class_ids(y))
sum(apply(x, 1L, max)) / n
}
R/agreement.R:272
.cl_agreement_partition_PS untypeabletyped
unbound variable (line 299)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.012 s
source
.cl_agreement_partition_PS <-
function(x, y)
{
## Prediction Strength as used in Tibshirani and Walter (2005),
## "Cluster Validation by Prediction Strength", JCGS.
## See Eqn 2.1 in the reference: this is
## min_l rate of different objects in the same class in partition
## A and in class l in partition B,
## where the min is taken over all classes l of partition B.
x <- table(cl_class_ids(x), cl_class_ids(y))
s <- rowSums(x)
min((rowSums(x ^ 2) - s) / (s * (s - 1)), na.rm = TRUE)
}
R/agreement.R:288
.cl_agreement_hierarchy_euclidean untypeabletyped
unbound variable (line 352)
unbound: .cl_dissimilarity_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_euclidean
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.007 s
source
.cl_agreement_hierarchy_euclidean <-
function(x, y)
1 / (1 + .cl_dissimilarity_hierarchy_euclidean(x, y))
R/agreement.R:350
.cl_agreement_hierarchy_manhattan untypeabletyped
unbound variable (line 358)
unbound: .cl_dissimilarity_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_manhattan
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.006 s
source
.cl_agreement_hierarchy_manhattan <-
function(x, y)
1 / (1 + .cl_dissimilarity_hierarchy_manhattan(x, y))
R/agreement.R:356
.cl_agreement_hierarchy_cophenetic untypeabletyped
unbound variable (line 366)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.085 s
source
.cl_agreement_hierarchy_cophenetic <-
function(x, y)
{
## Cophenetic correlation.
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
cor(cl_object_dissimilarities(x), cl_object_dissimilarities(y))
}
R/agreement.R:362
.cl_agreement_hierarchy_angle untypeabletyped
unbound variable (line 378)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.096 s
source
.cl_agreement_hierarchy_angle <-
function(x, y)
{
## Angle between ultrametrics.
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u_x <- cl_object_dissimilarities(x)
u_y <- cl_object_dissimilarities(y)
sum(u_x * u_y) / sqrt(sum(u_x ^ 2) * sum(u_y ^ 2))
}
R/agreement.R:374
.cl_agreement_hierarchy_gamma untypeabletyped
unbound variable (line 390)
unbound: .cl_dissimilarity_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_gamma
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.006 s
source
.cl_agreement_hierarchy_gamma <-
function(x, y)
1 - .cl_dissimilarity_hierarchy_gamma(x, y)
R/agreement.R:388
[.cl_agreement untypeabletyped
unbound variable (line 397)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any with { description: any, any }, i: any, j: any) -> any)<>
timing: 0.031 s
source
"[.cl_agreement" <-
function(x, i, j)
{
y <- NextMethod("[")
if(!inherits(y, "cl_agreement")) {
description <- attr(x, "description")
return(cl_cross_proximity(y, description = description,
class = "cl_cross_agreement"))
}
y
}
R/agreement.R:394
R/ultrametric.R
.non_ultrametricity untypeable
unbound variable (line 798)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
timing: 0.047 s
source
.non_ultrametricity <-
function(x, max = FALSE)
{
if(!is.matrix(x))
x <- .symmetric_matrix_from_veclh(x)
.C(C_deviation_from_ultrametricity,
as.double(x),
as.integer(nrow(x)),
fn = double(1L),
as.logical(max))$fn
}
R/ultrametric.R:794
.cl_ultrametric_from_veclh untypeabletyped
unbound variable (line 34)
unbound: .non_ultrametricity — one of the package’s own names, itself untyped
error detail
name: .non_ultrametricity
gradual mode: typed
((x: any, size: any?, labels: any?, meta: null?) -> any)<>
timing: 0.039 s
source
.cl_ultrametric_from_veclh <-
function(x, size = NULL, labels = NULL, meta = NULL)
{
if(.non_ultrametricity(x) > 0)
stop("Not a valid ultrametric.")
u <- cl_proximity(x, "Ultrametric distances",
labels = labels, size = size,
class = c("cl_ultrametric", "cl_dissimilarity",
"cl_proximity", "dist"))
if(!is.null(meta))
attr(u, "meta") <- meta
u
}
R/ultrametric.R:31
cl_ultrametric untypeabletyped
unbound variable (line 10)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }, size: any?, labels: null?) -> any)<>
timing: 0.095 s
source
cl_ultrametric <-
function(x, size = NULL, labels = NULL)
{
if(inherits(x, "cl_hierarchy")) {
## <NOTE>
## Strictly, not every hierarchy corresponds to an ultrametric.
## </NOTE>
return(cl_ultrametric(.get_representation(x),
size = size, labels = labels))
}
else if(!inherits(x, "cl_ultrametric")) {
## Try using cophenetic().
## This starts by coercing to hclust, which has methods for all
## currently supported hierarchical classification methods.
## To support others, either provide as.hclust methods for
## these, or make cl_ultrametric() generic and add methods.
## Or use the fact that in R >= 2.1.0, stats::cophenetic() is
## generic.
out <- cophenetic(x)
}
else {
out <- x
if(is.null(labels))
labels <- attr(x, "Labels")
}
.cl_ultrametric_from_veclh(out, labels = labels, size = size)
}
R/ultrametric.R:3
as.cl_ultrametric untypeabletyped
unbound variable (line 49)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_ultrametric <-
function(x)
UseMethod("as.cl_ultrametric")
R/ultrametric.R:47
as.cl_ultrametric.default untypeabletyped
unbound variable (line 55)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.017 s
source
as.cl_ultrametric.default <-
function(x)
{
if(inherits(x, "cl_ultrametric"))
x
else if(is.atomic(x))
.cl_ultrametric_from_veclh(x)
else
cl_ultrametric(x)
}
R/ultrametric.R:50
as.cl_ultrametric.matrix untypeabletyped
unbound variable (line 62)
unbound: row — a name the prelude does not declare
error detail
name: row
gradual mode: typed
((x: any) -> any)<>
timing: 0.006 s
source
as.cl_ultrametric.matrix <-
function(x)
.cl_ultrametric_from_veclh(x[row(x) > col(x)],
labels = rownames(x))
R/ultrametric.R:60
as.dendrogram.cl_ultrametric untypeabletyped
unbound variable (line 69)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((object: any, ...: any) -> any)<>
timing: 0.003 s
source
as.dendrogram.cl_ultrametric <-
function(object, ...)
as.dendrogram(as.hclust(object), ...)
R/ultrametric.R:67
as.hclust.cl_ultrametric untypeabletyped
unbound variable (line 81)
unbound: hclust — a name the prelude does not declare
error detail
name: hclust
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.004 s
source
as.hclust.cl_ultrametric <-
function(x, ...)
{
## Hierarchical clustering with single linkage gives the minimal
## ultrametric dominated by a dissimilarity, see e.g. Bock (1974,
## Theorem 39.2). Hence, hclust(method = "single") on an
## ultrametric gives the hclust representation of the associated
## dendrogram.
hclust(x, "single")
}
R/ultrametric.R:73
cophenetic.cl_ultrametric untypeabletyped
unbound variable (line 88)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cophenetic.cl_ultrametric <-
function(x)
as.dist(x)
R/ultrametric.R:86
plot.cl_ultrametric untypeabletyped
unbound variable (line 94)
unbound: as.dendrogram — a name the prelude does not declare
error detail
name: as.dendrogram
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
plot.cl_ultrametric <-
function(x, ...)
plot(as.dendrogram(x), ...)
R/ultrametric.R:92
.cl_ultrametric_with_meta_added untypeabletyped
unbound variable (line 859)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((x: any, meta: any?) -> any)<>
timing: 0.006 s
source
.cl_ultrametric_with_meta_added <-
function(x, meta = NULL)
{
## An alternative to adding a 'meta' argument to cl_ultrametric().
attr(x, "meta") <- meta
x
}
R/ultrametric.R:855
.make_penalty_function_ultrametric untypeabletyped
unbound variable (line 244)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: any) -> ((d: any) -> any)<>)<>
timing: 0.013 s
source
.make_penalty_function_ultrametric <-
function(n)
function(d) {
## Smooth penalty function measuring the extent of violation of
## the ultrametricity constraint. Also ensure nonnegativity ...
(.non_ultrametricity(.symmetric_matrix_from_veclh(d, n))
+ sum(pmin(d, 0) ^ 2))
}
R/ultrametric.R:239
.make_penalty_gradient_ultrametric untypeabletyped
unbound variable (line 252)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: dbl1<~@"*", ...>) -> ((d: any) -> any)<>)<>
timing: 0.022 s
source
.make_penalty_gradient_ultrametric <-
function(n)
function(d) {
gr <- matrix(.C(C_deviation_from_ultrametricity_gradient,
as.double(.symmetric_matrix_from_veclh(d, n)),
as.integer(n),
gr = double(n * n))$gr,
n, n)
gr[row(gr) > col(gr)] + 2 * sum(pmin(d, 0))
}
R/ultrametric.R:248
.ultrametrify untypeabletyped
unbound variable (line 877)
unbound: .dist_from_vector — one of the package’s own names, itself untyped
error detail
name: .dist_from_vector
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
.ultrametrify <-
function(x)
{
## Ensure ultrametricity.
## In earlier versions, function
## .cl_ultrametric_from_ultrametric_approximation() tried rounding
## to non-ultrametric significance, using
## round(x, floor(abs(log10(.non_ultrametricity(x, max = TRUE)))))
## which is nice but does not guarantee ultrametricity (and may
## result in poorer approximations than what we use now).
## Hence, let us use single linkage hierarchical clustering which
## gives the best dominated ultrametric approximation.
cophenetic(hclust(.dist_from_vector(x), "single"))
}
R/ultrametric.R:865
.ls_fit_ultrametric_by_SUMT untypeable
untypeable application of base::$ (line 175)
error detail
argument: @({ }<> | 'control, "nruns"<>)
failing call: base::$(list(), "nruns")timing: 0.308 s
source
.ls_fit_ultrametric_by_SUMT <-
function(x, weights = 1, control = list())
{
## Fit an ultrametric to a dissimilarity by minimizing euclidean
## dissimilarity subject to the ultrametric constraint, using the
## sequential algorithm of de Soete (1984) with a slight change: we
## try to ensure that what we obtain satisfies the constraints
## "exactly" rather than approximately. We (currently?) do that via
## rounding ...
## <NOTE>
## This fits and hence returns an ultrametric, *not* the hierarchy
## corresponding to the ultrametric.
## </NOTE>
w <- weights / sum(weights)
## Control parameters:
## nruns,
nruns <- control$nruns
## start.
start <- control$start
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
## If x is an ultrametric, or satisfies the ultrametricity
## constraints, return it.
if(inherits(x, "cl_ultrametric")
|| (.non_ultrametricity(x, max = TRUE) == 0))
return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
list(objval = 0)))
## For the time being, use a simple minimizer.
n <- attr(x, "Size")
labels <- attr(x, "Labels")
## Handle missing values in x along the lines of de Soete (1984):
## set the corresponding weights to 0, and impute by the weighted
## mean.
ind <- which(is.na(x))
if(any(ind)) {
w[ind] <- 0
x[ind] <- weighted.mean(x, w, na.rm = TRUE)
}
## We follow de Soete's notation, and use the veclh's (vector of
## lower half, in S the same as x[lower.tri(x)]) of the respective
## proximity objects.
L <- function(d) sum(w * (x - d) ^ 2)
P <- .make_penalty_function_ultrametric(n)
grad_L <- function(d) 2 * w * (d - x)
grad_P <- .make_penalty_gradient_ultrametric(n)
if(is.null(start)) {
## Initialize by "random shaking". Use sd() for simplicity.
start <- replicate(nruns,
x + rnorm(length(x), sd = sd(x) / sqrt(3)),
simplify = FALSE)
}
## And now ...
out <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))
d <- .ultrametrify(out$x)
meta <- list(objval = L(d))
.cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:156
.ls_fit_ultrametric_by_iterative_projection untypeable
unbound variable (line 273)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.189 s
source
.ls_fit_ultrametric_by_iterative_projection <-
function(x, weights = 1, control = list())
{
if(any(diff(weights) != 0))
warning("Non-identical weights currently not supported.")
labels <- attr(x, "Labels")
n <- attr(x, "Size")
x <- as.matrix(x)
## Control parameters:
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 10000L
## nruns,
nruns <- control$nruns
## order,
order <- control$order
## tol,
tol <- control$tol
if(is.null(tol))
tol <- 1e-8
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle order and nruns.
if(!is.null(order)) {
if(!is.list(order))
order <- as.list(order)
if(!all(vapply(order,
function(o) all(sort(o) == seq_len(n)),
NA)))
stop("All given orders must be valid permutations.")
}
else {
if(is.null(nruns))
nruns <- 1L
order <- replicate(nruns, sample(n), simplify = FALSE)
}
## <NOTE>
## Adjust in case support for non-identical weights is added.
L <- function(d) sum((x - d) ^ 2)
## </NOTE>
d_opt <- NULL
v_opt <- Inf
for(run in seq_along(order)) {
if(verbose)
message(gettextf("Iterative projection run: %d", run))
d <- .C(C_ls_fit_ultrametric_by_iterative_projection,
as.double(x),
as.integer(n),
as.integer(order[[run]] - 1L),
as.integer(maxiter),
iter = integer(1L),
as.double(tol),
as.logical(verbose))[[1L]]
v <- L(d)
if(v < v_opt) {
v_opt <- v
d_opt <- d
}
}
d <- .ultrametrify(as.dist(matrix(d_opt, n)))
meta <- list(objval = L(d))
.cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:270
.ls_fit_ultrametric_by_iterative_reduction untypeable
unbound variable (line 350)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.220 s
source
.ls_fit_ultrametric_by_iterative_reduction <-
function(x, weights = 1, control = list())
{
if(any(diff(weights) != 0))
warning("Non-identical weights currently not supported.")
labels <- attr(x, "Labels")
n <- attr(x, "Size")
x <- as.matrix(x)
## Control parameters:
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 10000L
## nruns,
nruns <- control$nruns
## order,
order <- control$order
## tol,
tol <- control$tol
if(is.null(tol))
tol <- 1e-8
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle order and nruns.
if(!is.null(order)) {
if(!is.list(order))
order <- as.list(order)
if(!all(vapply(order,
function(o) all(sort(o) == seq_len(n)),
NA)))
stop("All given orders must be valid permutations.")
}
else {
if(is.null(nruns))
nruns <- 1L
order <- replicate(nruns, sample(n), simplify = FALSE)
}
## <NOTE>
## Adjust in case support for non-identical weights is added.
L <- function(d) sum((x - d) ^ 2)
## </NOTE>
d_opt <- NULL
v_opt <- Inf
for(run in seq_along(order)) {
if(verbose)
message(gettextf("Iterative reduction run: %d", run))
d <- .C(C_ls_fit_ultrametric_by_iterative_reduction,
as.double(x),
as.integer(n),
as.integer(order[[run]] - 1L),
as.integer(maxiter),
iter = integer(1L),
as.double(tol),
as.logical(verbose))[[1L]]
v <- L(d)
if(v < v_opt) {
v_opt <- v
d_opt <- d
}
}
d <- .ultrametrify(as.dist(matrix(d_opt, n)))
meta <- list(objval = L(d))
.cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:347
ls_fit_ultrametric untypeable
unbound variable (line 103)
unbound: .cl_ultrametric_with_meta_added — one of the package’s own names, itself untyped
error detail
name: .cl_ultrametric_with_meta_added
timing: 0.202 s
source
ls_fit_ultrametric <-
function(x, method = c("SUMT", "IP", "IR"), weights = 1,
control = list())
{
if(inherits(x, "cl_ultrametric")) {
return(.cl_ultrametric_with_meta_added(x, list(objval = 0)))
} else if(is.cl_ensemble(x) || is.list(x)) {
## Might be given a list/ensemble of object dissimilarities.
## In this case, compute the suitably weighted average and
## proceed.
if(length(x) == 0L)
stop("Given ensemble contains no dissimilarities.")
## Let's be nice as usual ...
ind <- !vapply(x, .has_object_dissimilarities, NA)
if(any(ind))
x[ind] <- lapply(x[ind], as.dist)
x <- .weighted_mean_of_object_dissimilarities(x,
control$weights)
} else if(!inherits(x, "dist"))
x <- as.dist(x)
## Catch some special cases right away.
if(attr(x, "Size") <= 2L)
return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
list(objval = 0)))
if(.non_ultrametricity(x, max = TRUE) == 0)
return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
list(objval = 0)))
## Handle weights.
## This is somewhat tricky ...
if(is.matrix(weights)) {
weights <- as.dist(weights)
if(length(weights) != length(x))
stop("Argument 'weights' must be compatible with 'x'.")
}
else
weights <- rep_len(weights, length(x))
if(any(weights < 0))
stop("Argument 'weights' has negative elements.")
if(!any(weights > 0))
stop("Argument 'weights' has no positive elements.")
method <- match.arg(method)
switch(method,
SUMT = .ls_fit_ultrametric_by_SUMT(x, weights, control),
IP = {
.ls_fit_ultrametric_by_iterative_projection(x, weights,
control)
},
IR = {
.ls_fit_ultrametric_by_iterative_reduction(x, weights,
control)
})
}
R/ultrametric.R:98
.handle_weights_for_ultrametric_target_fitters untypeable
unbound variable (line 502)
unbound: rep_len — a name the prelude does not declare
error detail
name: rep_len
timing: 0.204 s
source
.handle_weights_for_ultrametric_target_fitters <-
function(weights, x)
{
## Handle weights for the ultrametric target fitters.
## This is somewhat tricky ...
if(is.matrix(weights)) {
if(any(dim(weights) != attr(x, "Size")))
stop("Argument 'weights' must be compatible with 'x'.")
}
else
weights <-
as.matrix(.dist_from_vector(rep_len(weights, length(x))))
if(any(weights < 0))
stop("Argument 'weights' has negative elements.")
if(!any(weights > 0))
stop("Argument 'weights' has no positive elements.")
weights
}
R/ultrametric.R:491
.fit_ultrametric_target untypeabletyped
unbound variable (line 455)
unbound: .handle_weights_for_ultrametric_target_fitters — one of the package’s own names, itself untyped
error detail
name: .handle_weights_for_ultrametric_target_fitters
gradual mode: typed
((x: any, y: any, w: any, fitter: any, distfun: null?) -> any)<>
timing: 0.182 s
source
.fit_ultrametric_target <-
function(x, y, w, fitter, distfun = NULL)
{
w <- .handle_weights_for_ultrametric_target_fitters(w, x)
## The documentation says that x should inherit from dist, so coerce
## to this if needed but if not a matrix (as we will coerce back to
## a matrix right away).
if(!inherits(x, "dist") && !is.matrix(x))
x <- as.dist(x)
x <- as.matrix(x)
y <- as.hclust(y)
n <- length(y$order)
ilist <- vector("list", n)
out <- matrix(0, n, n)
mat <- xlist <- wlist <- vector("list", n - 1L)
for(i in seq_len(n - 1L)) {
inds <- y$merge[i, ]
ids1 <- if(inds[1L] < 0) -inds[1L] else ilist[[inds[1L]]]
ids2 <- if(inds[2L] < 0) -inds[2L] else ilist[[inds[2L]]]
ilist[[i]] <- c(ids1, ids2)
mat[[i]] <- cbind(rep.int(ids1,
rep.int(length(ids2), length(ids1))),
rep.int(ids2, length(ids1)))
xlist[[i]] <- x[mat[[i]]]
wlist[[i]] <- w[mat[[i]]]
}
values <- pava(xlist, wlist, fitter)
for(i in seq_len(n - 1L))
out[mat[[i]]] <- values[i]
rownames(out) <- y$labels
u <- as.cl_ultrametric(out + t(out))
if(!is.null(distfun))
attr(u, "meta") <-
list(objval = distfun(as.dist(x), u, as.dist(w)))
u
}
R/ultrametric.R:452
ls_fit_ultrametric_target untypeable
unbound variable (line 430)
unbound: mean — a name the prelude does not declare
error detail
name: mean
timing: 0.031 s
source
ls_fit_ultrametric_target <-
function(x, y, weights = 1)
{
fitter <- if(identical(weights, 1)) # Default.
function(x, w) mean(x)
else
function(x, w) weighted.mean(x, w)
distfun <- function(x, u, w) sqrt(sum(w * (x - u) ^ 2))
.fit_ultrametric_target(x, y, weights, fitter, distfun)
}
R/ultrametric.R:426
l1_fit_ultrametric_target untypeable
unbound variable (line 443)
unbound: median — a name the prelude does not declare
error detail
name: median
timing: 0.031 s
source
l1_fit_ultrametric_target <-
function(x, y, weights = 1)
{
fitter <- if(identical(weights, 1)) # Default.
function(x, w) median(x)
else
function(x, w) weighted_median(x, w)
distfun <- function(x, u, w) sum(w * abs(x - u))
.fit_ultrametric_target(x, y, weights, fitter, distfun)
}
R/ultrametric.R:439
.l1_fit_ultrametric_by_IRIP untypeable
untypeable application of base::$ (line 630)
error detail
argument: @({ }<> | 'control, "MIN"<>)
failing call: base::$(list(), "MIN")timing: 0.366 s
source
.l1_fit_ultrametric_by_IRIP <-
function(x, weights = 1, control = list())
{
## An attempt of implementing "Iteratively Reweighted Iterative
## Projection" as described in Smith (2000, 2001), Journal of
## Classification. Note that this suggests using the Iterative
## Projection of Hubert and Arabie (1995), which we cannot as we
## have not (yet?) implemented this for the weighted case. Hence,
## we use our SUMT least squares ultrametric fitter instead.
##
## However, we never got this to converge properly ...
w <- weights / sum(weights)
## Control parameters:
## MIN,
MIN <- control$MIN
if(is.null(MIN))
MIN <- 1e-3
## (A rather small cut-off which worked best in the cases we tried.)
## eps,
eps <- control$eps
if(is.null(eps))
eps <- 1e-6
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 100L
## reltol,
reltol <- control$reltol
if(is.null(reltol))
reltol <- 1e-6
## start,
start <- control$start
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
n <- attr(x, "Size")
labels <- attr(x, "Labels")
L <- function(d) sum(w * abs(x - d))
## Initialize by "random shaking" as for the L2 SUMT, but perhaps we
## should not do this? [Or do it differently?]
u <- if(is.null(start))
x + rnorm(length(x), sd = sd(x) / 3)
else
start
## (No multiple runs for the time being.)
L_new <- L(u)
iter <- 1L
while(iter <= maxiter) {
if(verbose)
message(gettextf("Outer iteration: %d", iter))
L_old <- L_new
u_old <- u
weights <- w / pmax(abs(u - x), MIN)
u <- .ls_fit_ultrametric_by_SUMT(x,
weights = weights,
control = as.list(control$control))
## Use some control arguments lateron ...
L_new <- L(u)
delta_L <- L_old - L_new
delta_u <- max(abs(u_old - u))
if(verbose)
message(gettextf("Change: u: %g L: %g", delta_u, delta_L))
if((delta_u < eps) ||
((delta_L >= 0) &&
(delta_L <= reltol * (abs(L_old) + reltol))))
break
iter <- iter + 1L
}
d <- .ultrametrify(u)
meta <- list(objval = L(d), status = as.integer(iter == maxiter))
.cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:614
.l1_fit_ultrametric_by_SUMT untypeable
untypeable application of base::$ (line 561)
error detail
argument: @({ }<> | 'control, "gradient"<>)
failing call: base::$(list(), "gradient")timing: 0.367 s
source
.l1_fit_ultrametric_by_SUMT <-
function(x, weights = 1, control = list())
{
## Try a SUMT with "pseudo-gradients".
w <- weights / sum(weights)
## Control parameters:
## gradient,
gradient <- control$gradient
if(is.null(gradient))
gradient <- TRUE
## nruns,
nruns <- control$nruns
## start.
start <- control$start
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
## For the time being, use a simple minimizer.
n <- attr(x, "Size")
labels <- attr(x, "Labels")
L <- function(d) sum(w * abs(d - x))
P <- .make_penalty_function_ultrametric(n)
if(gradient) {
grad_L <- function(d) w * sign(d - x)
grad_P <- .make_penalty_gradient_ultrametric(n)
} else
grad_L <- grad_P <- NULL
if(is.null(start)) {
## Initialize by "random shaking". Use sd() for simplicity.
start <- replicate(nruns,
x + rnorm(length(x), sd = sd(x) / sqrt(3)),
simplify = FALSE)
}
## And now ...
out <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))
d <- .ultrametrify(out$x)
meta <- list(objval = L(d))
.cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:552
l1_fit_ultrametric untypeable
unbound variable (line 517)
unbound: .cl_ultrametric_with_meta_added — one of the package’s own names, itself untyped
error detail
name: .cl_ultrametric_with_meta_added
timing: 0.156 s
source
l1_fit_ultrametric <-
function(x, method = c("SUMT", "IRIP"), weights = 1,
control = list())
{
if(inherits(x, "cl_ultrametric"))
return(.cl_ultrametric_with_meta_added(x, list(objval = 0)))
if(!inherits(x, "dist"))
x <- as.dist(x)
## Catch some special cases right away.
if(attr(x, "Size") <= 2L)
return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
list(objval = 0)))
if(.non_ultrametricity(x, max = TRUE) == 0)
return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
list(objval = 0)))
## Handle weights.
## This is somewhat tricky ...
if(is.matrix(weights)) {
weights <- as.dist(weights)
if(length(weights) != length(x))
stop("Argument 'weights' must be compatible with 'x'.")
}
else
weights <- rep_len(weights, length(x))
if(any(weights < 0))
stop("Argument 'weights' has negative elements.")
if(!any(weights > 0))
stop("Argument 'weights' has no positive elements.")
method <- match.arg(method)
switch(method,
SUMT = .l1_fit_ultrametric_by_SUMT(x, weights, control),
IRIP = .l1_fit_ultrametric_by_IRIP(x, weights, control))
}
R/ultrametric.R:512
ls_fit_sum_of_ultrametrics untypeable
unbound variable (line 702)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
timing: 0.319 s
source
ls_fit_sum_of_ultrametrics <-
function(x, nterms = 1, weights = 1, control = list())
{
if(!inherits(x, "dist"))
x <- as.dist(x)
## We could catch some special cases right away: if x already is an
## ultrametric then the fit would be a list with x and nterms - 1
## zero ultrametrics ...
## Control parameters:
## eps,
eps <- control$eps
if(is.null(eps))
eps <- 1e-6
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 100L
## method,
method <- control$method
if(is.null(method))
method <- "SUMT"
## reltol,
reltol <- control$reltol
if(is.null(reltol))
reltol <- 1e-6
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Do this at last.
control <- as.list(control$control)
## And be nice ...
if(identical(method, "SUMT") && is.null(control$nruns))
control$nruns <- 10L
L <- function(u)
sum((x - rowSums(matrix(unlist(u), ncol = nterms))) ^ 2)
## Init.
u <- rep.int(list(as.cl_ultrametric(0 * x)), nterms)
L_new <- L(u)
## Loop.
iter <- 1L
while(iter <= maxiter) {
if(verbose)
message(gettextf("Iteration: %d", iter))
L_old <- L_new
delta_u <- 0
for(i in seq_len(nterms)) {
if(verbose)
message(gettextf("Term: %d", i))
u_old <- u[[i]]
## Compute residual r = x - \sum_{j: j \ne i} u(j)
r <- x - rowSums(matrix(unlist(u[-i]), ncol = nterms - 1L))
## Fit residual.
u[[i]] <- ls_fit_ultrametric(r, method, weights, control)
## Accumulate change.
change <- max(abs(u[[i]] - u_old))
if(verbose)
message(gettextf("Change: %g", change))
delta_u <- max(delta_u, change)
}
L_new <- L(u)
delta_L <- L_old - L_new
if(verbose)
message(gettextf("Overall change: u: %g L: %g\n",
delta_u, delta_L))
if((delta_u < eps) ||
((delta_L >= 0) &&
(delta_L <= reltol * (abs(L_old) + reltol))))
break
iter <- iter + 1L
}
.structure(u, objval = L_new, status = as.integer(iter == maxiter))
}
R/ultrametric.R:698
as.matrix.hclust untypeabletyped
unbound variable (line 790)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.004 s
source
as.matrix.hclust <-
function(x, ...)
as.matrix(cophenetic(x))
R/ultrametric.R:788
.cl_ultrametric_from_classes untypeable
unbound variable (line 817)
unbound: duplicated — a name the prelude does not declare
error detail
name: duplicated
timing: 0.059 s
source
.cl_ultrametric_from_classes <-
function(x)
{
## Compute an ultrametric from a hierarchy of classes (i.e., an
## n-tree).
labels <- attr(x, "labels")
## Ensure we have no duplicates.
x <- x[!duplicated(x)]
## .get_classes_in_hierarchy() orders according to cardinality, but
## a consensus method may forget to ...
x[] <- x[order(lengths(x))]
## Get the objects (unique codes in the classes).
objects <- sort(unique(unlist(x)))
## (Could also look at the classes of length 1.)
## Recursively compute the heights of the classes.
heights <- double(length = length(x))
for(i in which(lengths(x) > 1L)) {
## Find the relevant classes.
j <- sapply(x[seq_len(i - 1L)],
function(s) all(s %in% x[[i]]))
heights[i] <- max(heights[j]) + 1
}
## Next, create an incidence matrix (objects by classes).
incidences <- sapply(x, function(s) objects %in% s)
## Now that we have the heights and incidences, we can compute
## distances, using the idea that
## distance(i, j) = min(height(A): A contains i and j)
n <- length(objects)
d <- matrix(0, n, n)
for(i in objects)
d[i, ] <- heights[apply((rep(incidences[i, ], each = n)
& incidences),
1L, which.max)]
dimnames(d) <- rep.int(list(labels), 2L)
as.cl_ultrametric(d)
}
R/ultrametric.R:808
R/dissimilarity.R
cl_dissimilarity untypeable
unbound variable (line 6)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.150 s
source
cl_dissimilarity <-
function(x, y = NULL, method = "euclidean", ...)
{
x <- as.cl_ensemble(x)
is_partition_ensemble <-
(inherits(x, "cl_partition_ensemble")
|| all(vapply(x, .has_object_memberships, NA)))
## Be nice.
if(is.character(y) || is.function(y)) {
method <- y
y <- NULL
}
if(is.function(method))
method_name <- "user-defined method"
else {
if(!inherits(method, "cl_dissimilarity_method")) {
## Get the method definition and description from the
## registry.
type <- ifelse(is_partition_ensemble,
"partition", "hierarchy")
method <- get_cl_dissimilarity_method(method, type)
}
method_name <- method$description
method <- method$definition
}
if(!is.null(y)) {
y <- as.cl_ensemble(y)
is_partition_ensemble_y <-
(inherits(y, "cl_partition_ensemble")
|| all(vapply(x, .has_object_memberships, NA)))
if(!identical(is_partition_ensemble, is_partition_ensemble_y))
stop("Cannot mix partitions and hierarchies.")
if(n_of_objects(x) != n_of_objects(y))
stop("All clusterings must have the same number of objects.")
## Build a cross-proximity object of cross-dissimilarities.
d <- matrix(0, length(x), length(y))
for(j in seq_along(y))
d[, j] <- sapply(x, method, y[[j]], ...)
dimnames(d) <- list(names(x), names(y))
return(cl_cross_proximity(d, method_name,
class = "cl_cross_dissimilarity"))
}
## Otherwise, build a proximity object of dissimilarities.
n <- length(x)
d <- vector("list", length = n - 1L)
ind <- seq_len(n)
while(length(ind) > 1L) {
j <- ind[1L]
ind <- ind[-1L]
d[[j]] <- sapply(x[ind], method, x[[j]], ...)
}
cl_proximity(unlist(d),
method_name,
labels = names(x),
size = n,
class = c("cl_dissimilarity", "cl_proximity", "dist"))
}
R/dissimilarity.R:3
.cl_dissimilarity_partition_euclidean untypeabletyped
unbound variable (line 71)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.012 s
source
.cl_dissimilarity_partition_euclidean <-
function(x, y)
{
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
## Match classes from conforming memberships.
ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
sqrt(sum((M_x - M_y[, ind]) ^ 2))
}
R/dissimilarity.R:68
.cxdist untypeabletimeout
unbound variable (line 555)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: timeout
timing: 0.106 s
source
.cxdist <-
function(A, B, method = c("euclidean", "manhattan", "minkowski"), ...)
{
## Return the column cross distance matrix of A and B.
## I.e., the matrix C = [c_{j,k}] with
## c_{j,k} = distance(A[, j], B[, k])
## Currently, only Manhattan (L1) distances are provided.
## Extensions to Minkowski or even more distances (a la dist())
## could be added eventually.
## <NOTE>
## Possible implementations include
##
## foo_a <- function(A, B)
## apply(B, 2, function(u) colSums(abs(A - u)))
## foo_d <- function(A, B) {
## out <- as.matrix(dist(rbind(t(A), t(B)), "manhattan"))
## dimnames(out) <- NULL
## nc_B <- NCOL(B)
## out[seq(from = NCOL(A) + 1, length.out = nc_B), seq_len(nc_B)]
## }
## foo_f <- function(A, B) {
## out <- matrix(0, NCOL(A), NCOL(B))
## for(j in seq_len(NCOL(A)))
## for(k in seq_len(NCOL(B)))
## out[j, k] = sum(abs(A[, j] - B[, k]))
## out
## }
##
## The one actually used seems to be the best performer, with the
## "for" version a close second (note that "typically", A and B have
## much fewer columns than rows).
## only few columns
method <- match.arg(method)
## Workhorse.
FOO <- switch(method,
"euclidean" =
function(M) sqrt(colSums(M ^ 2)),
"manhattan" =
function(M) colSums(abs(M)),
"minkowski" = {
## Power needs to be given.
p <- list(...)[[1L]]
function(M)
(colSums(abs(M) ^ p)) ^ (1 / p)
})
out <- matrix(0, NCOL(A), NCOL(B))
for(k in seq_len(NCOL(B)))
out[, k] <- FOO(A - B[, k])
out
}
R/dissimilarity.R:516
.cl_dissimilarity_partition_manhattan untypeabletyped
unbound variable (line 84)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.012 s
source
.cl_dissimilarity_partition_manhattan <-
function(x, y)
{
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
C <- .cxdist(M_x, M_y, "manhattan")
ind <- solve_LSAP(C)
sum(C[cbind(seq_along(ind), ind)])
}
R/dissimilarity.R:81
.cl_dissimilarity_partition_comemberships untypeabletyped
unbound variable (line 108)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.025 s
source
.cl_dissimilarity_partition_comemberships <-
function(x, y)
{
## We used to have the straightforward
## C_x <- tcrossprod(cl_membership(x)) # M_x M_x'
## C_y <- tcrossprod(cl_membership(y)) # M_y M_y'
## sum((C_x - C_y) ^ 2) / n_of_objects(x) ^ 2
## But note that
## \| AA' - BB' \|^2
## = tr((AA' - BB')'(AA' - BB')
## = tr(A'A A'A) - 2 tr(A'B B'A) + tr(B'B B'B)
## = \| A'A \|^2 - 2 \| A'B \|^2 + \| B'B \|^2
## which can be computed much more efficiently as all involved cross
## product matrices are "small" ...
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
sqrt(sum(crossprod(M_x) ^ 2)
- 2 * sum(crossprod(M_x, M_y) ^ 2)
+ sum(crossprod(M_y) ^ 2))
}
R/dissimilarity.R:94
.cl_dissimilarity_partition_Rand untypeable
unbound variable (line 140)
unbound: .cl_agreement_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Rand
timing: 0.007 s
source
.cl_dissimilarity_partition_Rand <-
function(x, y)
{
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
1 - .cl_agreement_partition_Rand(x, y)
}
R/dissimilarity.R:134
.cl_dissimilarity_partition_symdiff untypeabletyped
unbound variable (line 128)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.005 s
source
.cl_dissimilarity_partition_symdiff <-
function(x, y)
{
## Cardinality of the symmetric difference of the partitions
## regarded as binary equivalence relations, i.e., the number of
## discordant pairs.
## Handle soft partitions using the corresponding hard ones.
## (At least, for the time being.)
n <- n_of_objects(x)
.cl_dissimilarity_partition_Rand(x, y) * choose(n, 2)
}
R/dissimilarity.R:118
.cl_dissimilarity_partition_GV1 untypeabletyped
unbound variable (line 148)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 6.19 s
source
.cl_dissimilarity_partition_GV1 <-
function(x, y)
{
k_x <- n_of_classes(x)
k_y <- n_of_classes(y)
M_x <- cl_membership(x, k_x)
M_y <- cl_membership(y, k_y)
C <- outer(colSums(M_x ^ 2), colSums(M_y ^ 2), `+`) -
2 * crossprod(M_x, M_y)
if(k_x < k_y)
C <- rbind(C, matrix(0, nrow = k_y - k_x, ncol = k_y))
else if(k_x > k_y)
C <- cbind(C, matrix(0, nrow = k_x, ncol = k_x - k_y))
ind <- solve_LSAP(C)
sqrt(sum(C[cbind(seq_along(ind), ind)]))
## (Note that this sum really only includes matched non-dummy
## classes.)
}
R/dissimilarity.R:145
.cl_dissimilarity_partition_BA_A untypeabletyped
unbound variable (line 169)
unbound: as.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: as.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.005 s
source
.cl_dissimilarity_partition_BA_A <-
function(x, y)
{
.cl_dissimilarity_partition_manhattan(as.cl_hard_partition(x),
as.cl_hard_partition(y)) / 2
## Could to this more efficiently, of course ...
}
R/dissimilarity.R:166
.cl_dissimilarity_partition_BA_C untypeabletyped
unbound variable (line 179)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.008 s
source
.cl_dissimilarity_partition_BA_C <-
function(x, y)
{
n_of_classes(x) + n_of_classes(y) - 2 * n_of_classes(cl_join(x, y))
}
R/dissimilarity.R:176
.cl_dissimilarity_partition_BA_D untypeabletyped
unbound variable (line 185)
unbound: .cl_dissimilarity_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Rand
gradual mode: typed
any
timing: 0.000 s
source
.cl_dissimilarity_partition_BA_D <-
.cl_dissimilarity_partition_Rand
R/dissimilarity.R:184
.cl_dissimilarity_partition_BA_E untypeabletyped
unbound variable (line 192)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.029 s
source
.cl_dissimilarity_partition_BA_E <-
function(x, y)
{
z <- table(cl_class_ids(x), cl_class_ids(y))
z <- z / sum(z)
## Average mutual information between the partitions.
y <- outer(rowSums(z), colSums(z))
i <- which((z > 0) & (y > 0))
I <- sum(z[i] * log(z[i] / y[i]))
## Entropy of meet(x, y).
i <- which(z > 0)
H <- - sum(z[i] * log(z[i]))
1 - I / H
}
R/dissimilarity.R:189
.cl_dissimilarity_partition_VI untypeabletyped
unbound variable (line 214)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.045 s
source
.cl_dissimilarity_partition_VI <-
function(x, y, weights = 1)
{
## Variation of information for general "soft clusterings", cf
## Section 5.2. in Meila (2002).
weights <- rep_len(weights, n_of_objects(x))
weights <- weights / sum(weights)
M_x <- cl_membership(x)
## Weighted marginal distribution of x:
m_x <- colSums(weights * M_x)
M_y <- cl_membership(y)
## Weighted marginal distribution of y:
m_y <- colSums(weights * M_y)
gamma <- crossprod(weights * M_x, M_y)
delta <- outer(m_x, m_y)
## Entropy of x:
H_x <- - sum(m_x * log(ifelse(m_x > 0, m_x, 1)))
## Entropy of y:
H_y <- - sum(m_y * log(ifelse(m_y > 0, m_y, 1)))
## VI is H_x + H_y minus twice the (weighted) joint information.
i <- which((gamma > 0) & (delta > 0))
H_x + H_y - 2 * sum(gamma[i] * log(gamma[i] / delta[i]))
}
R/dissimilarity.R:209
.cl_dissimilarity_partition_Mallows untypeable
unbound variable (line 256)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 0.052 s
source
.cl_dissimilarity_partition_Mallows <-
function(x, y, p = 1, alpha = NULL, beta = NULL)
{
## Currently, no "real" primal-dual solver for minimum cost flow
## problems, and lpSolve::lp.transport() seems to work only for
## integer bounds. Hence, rather than using
##
## C <- .cxdist(cl_membership(x), cl_membership(y),
## "minkowski", p) ^ p
## n_x <- nrow(C)
## n_y <- ncol(C)
## if(is.null(alpha))
## alpha <- rep.int(1 / n_x, n_x)
## else {
## alpha <- rep_len(alpha, n_x)
## alpha <- alpha / sum(alpha)
## }
##
## etc right away, ensure a square cost matrix so that we can have
## integer bounds for at least the default case.
k <- max(n_of_classes(x), n_of_classes(y))
M_x <- cl_membership(x, k)
M_y <- cl_membership(y, k)
C <- .cxdist(M_x, M_y, "minkowski", p) ^ p
if(is.null(alpha)) alpha <- rep.int(1, k)
if(is.null(beta)) beta <- rep.int(1, k)
lpSolve::lp.transport(C, "min",
rep.int("==", k), alpha,
rep.int("==", k), beta,
integers = NULL)$objval ^ (1 / p)
}
R/dissimilarity.R:235
.rxdist untypeabletyped
unbound variable (line 595)
unbound: sweep — a name the prelude does not declare
error detail
name: sweep
gradual mode: typed
(((A: any, B: any, method: (vec | null)?) -> empty)&((A: any, B: any, method: (vec | null)?, ...: dbl) -> any))<>
timing: 0.267 s
source
.rxdist <-
function(A, B, method = c("euclidean", "manhattan", "minkowski"), ...)
{
## Return the row cross distance matrix of A and B.
## I.e., the matrix C = [c_{j,k}] with
## c_{j,k} = distance(A[j, ], B[k, ])
## <NOTE>
## Could also do something like
## ind <- seq_len(NROW(B))
## as.matrix(dist(rbind(B, A)))[-ind, ind]
## but that is *very* inefficient for the "usual" data by prototype
## case (where NROW(B) << NROW(A)).
## </NOTE>
## No fancy pmatching for methods for the time being.
method <- match.arg(method)
## Workhorse: Full A, single row of b.
FOO <- switch(method,
"euclidean" =
function(A, b) sqrt(rowSums(sweep(A, 2, b) ^ 2)),
"manhattan" =
function(A, b) rowSums(abs(sweep(A, 2, b))),
"minkowski" = {
## Power needs to be given.
p <- list(...)[[1L]]
function(A, b)
(rowSums(abs(sweep(A, 2, b)) ^ p)) ^ (1 / p)
})
out <- matrix(0, NROW(A), NROW(B))
## Be nice: thanks to Wael Salem ZRAFI <zrafi.w.s@gmail.com> for
## suggesting this improvement.
if(!is.null(cnA <- colnames(A)) &&
!is.null(cnB <- colnames(B)) &&
!identical(cnA, cnB))
A <- A[, cnB, drop = FALSE]
for(k in seq_len(NROW(B)))
out[, k] <- FOO(A, B[k, ])
out
}
R/dissimilarity.R:574
.cl_dissimilarity_partition_CSSD untypeable
unbound variable (line 287)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 3.13 s
source
.cl_dissimilarity_partition_CSSD <-
function(x, y, L = NULL, alpha = NULL, beta = NULL, ...)
{
## Cluster Similarity Sensitive Distance.
## Reference: D. Zhou, J. Li and H. Zha (2005),
## A new Mallows distance based metric for comparing clusterings.
## See .cl_dissimilarity_partition_Mallows() re solving cost flow
## problems.
## Dissimilarity is defined by minimizing
## \sum_{k,l} (1 - 2 w_{kl} / (alpha_k + beta_l)) L_{kl}
## where
## L_{kl} = \sum_i m_{x;ik} m_{y;il} distance(p_{x;k}, p_{y;l})
## with m and p the memberships and prototypes, respectively.
## If we get matrices of prototypes, use .rxdist; otherwise, the
## user needs to specify an L function or matrix.
k_x <- n_of_classes(x)
k_y <- n_of_classes(y)
M_x <- cl_membership(x, k_x)
M_y <- cl_membership(y, k_y)
if(!is.matrix(L)) {
p_x <- cl_prototypes(x)
p_y <- cl_prototypes(y)
if(is.matrix(p_x) && is.matrix(p_y) && is.null(L))
L <- .rxdist(p_x, p_y, ...)
else if(is.function(L))
L <- L(p_x, p_y)
else
stop("Cannot compute prototype distances.")
}
C <- crossprod(M_x, M_y) * L
if(is.null(alpha)) alpha <- rep.int(1, k_x)
if(is.null(beta)) beta <- rep.int(1, k_y)
sum(C) - 2 * lpSolve::lp.transport(C / outer(alpha, beta, `+`),
"max",
rep.int("==", k_x), alpha,
rep.int("==", k_y), beta,
integers = NULL)$objval
}
R/dissimilarity.R:270
.cl_dissimilarity_hierarchy_euclidean untypeabletyped
unbound variable (line 316)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.110 s
source
.cl_dissimilarity_hierarchy_euclidean <-
function(x, y, weights = 1)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
sqrt(sum(weights * (u - v) ^ 2))
}
R/dissimilarity.R:313
.cl_dissimilarity_hierarchy_manhattan untypeabletyped
unbound variable (line 329)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.107 s
source
.cl_dissimilarity_hierarchy_manhattan <-
function(x, y, weights = 1)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
sum(weights * abs(u - v))
}
R/dissimilarity.R:326
.cl_dissimilarity_hierarchy_cophenetic untypeabletyped
unbound variable (line 342)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.097 s
source
.cl_dissimilarity_hierarchy_cophenetic <-
function(x, y)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
1 - cor(u, v) ^ 2
}
R/dissimilarity.R:339
.cl_dissimilarity_hierarchy_gamma untypeabletyped
unbound variable (line 360)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.104 s
source
.cl_dissimilarity_hierarchy_gamma <-
function(x, y)
{
## <NOTE>
## This is a dissimilarity measure that works for arbitrary
## dissimilarities, see e.g. Bock.
## (And the current implementation finally respects this ...)
## </NOTE>
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
n <- length(u)
.C(C_clue_dissimilarity_count_inversions,
as.double(u),
as.double(v),
as.integer(n),
count = double(1L)) $ count / choose(n, 2)
}
R/dissimilarity.R:352
.cl_dissimilarity_hierarchy_symdiff untypeabletyped
unbound variable (line 381)
unbound: cl_classes — one of the package’s own names, itself untyped
error detail
name: cl_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.013 s
source
.cl_dissimilarity_hierarchy_symdiff <-
function(x, y)
{
## Cardinality of the symmetric difference of the n-trees when
## regarded as sets of subsets (classes) of the set of objects.
x <- cl_classes(x)
y <- cl_classes(y)
sum(is.na(match(x, y))) + sum(is.na(match(y, x)))
}
R/dissimilarity.R:375
.cl_dissimilarity_hierarchy_Chebyshev untypeabletyped
unbound variable (line 391)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.092 s
source
.cl_dissimilarity_hierarchy_Chebyshev <-
function(x, y)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
max(abs(u - v))
}
R/dissimilarity.R:388
.cl_dissimilarity_hierarchy_Lyapunov untypeable
unbound variable (line 404)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
timing: 0.088 s
source
.cl_dissimilarity_hierarchy_Lyapunov <-
function(x, y)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
q <- cl_object_dissimilarities(x) / cl_object_dissimilarities(y)
if(is.matrix(q)) q <- q[lower.tri(q)]
log(max(q) / min(q))
}
R/dissimilarity.R:401
.cl_dissimilarity_hierarchy_BO untypeabletyped
unbound variable (line 456)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { .Data: any, height: list | null, any } with { Labels: null, any }, y: { .Data: any, height: list | null, any } with { Labels: null, any }, delta: any, ...: any) | (x: { .Data: any, height: vec | null, any } with { Labels: null, any }, y: { .Data: any, height: vec | null, any } with { Labels: null, any }, delta: any, ...: any) -> any)<>
timing: 0.445 s
source
.cl_dissimilarity_hierarchy_BO <-
function(x, y, delta, ...)
{
## Compute Boorman-Olivier (1973) dendrogram ("valued tree")
## dissimilarities of the form
##
## m_\delta(T_1, T_2)
## = \int_0^\infty \delta(P_1(\alpha), P_2(\alpha)) d\alpha
##
## where the trees (dendrograms) are defined as right-continuous
## maps from [0, \Infty) to the partition lattice.
## We can compute this as follows. Take the ultrametrics and use
## as.hclust() to detemine the heights \alpha_1(k) and \alpha_2(l)
## of the splits. Let \alpha_i be the sequence obtained by
## combining these two. Then
##
## m_\delta
## = \sum_{i=0}^{L-1} (\alpha_{i+1} - \alpha_i)
## \delta(P_1(\alpha_i), P_2(\alpha_i))
##
## We use cutree() for computing the latter partitions. As we
## already have the hclust representations, we should be able to do
## things more efficiently ...
if(inherits(x, "hclust"))
t_x <- x
else if(inherits(x, "cl_ultrametric"))
t_x <- as.hclust(x)
else if(is.cl_dendrogram(x))
t_x <- as.hclust(cl_ultrametric(x))
else
return(NA)
if(inherits(y, "hclust"))
t_y <- y
else if(inherits(y, "cl_ultrametric"))
t_y <- as.hclust(y)
else if(is.cl_dendrogram(y))
t_y <- as.hclust(cl_ultrametric(y))
else
return(NA)
if(is.unsorted(t_x$height) || is.unsorted(t_y$height))
return(NA)
alpha <- sort(unique(c(t_x$height, t_y$height)))
cuts_x <- cutree(t_x, h = alpha)
cuts_y <- cutree(t_y, h = alpha)
deltas <- mapply(cl_dissimilarity,
lapply(split(cuts_x, col(cuts_x)),
as.cl_partition),
lapply(split(cuts_y, col(cuts_y)),
as.cl_partition),
MoreArgs = list(delta, ...))
sum(diff(alpha) * deltas[-length(deltas)])
}
R/dissimilarity.R:414
.cl_dissimilarity_hierarchy_spectral untypeabletyped
unbound variable (line 476)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.089 s
source
.cl_dissimilarity_hierarchy_spectral <-
function(x, y)
{
if(!.has_object_dissimilarities(x) ||
!.has_object_dissimilarities(y))
return(NA)
u <- cl_object_dissimilarities(x)
v <- cl_object_dissimilarities(y)
svd(as.matrix(u - v))$d[1L]
}
R/dissimilarity.R:473
as.dist.cl_dissimilarity untypeabletyped
unbound variable (line 493)
unbound: match.call — a name the prelude does not declare
error detail
name: match.call
gradual mode: typed
((m: list<...>, diag: any?, upper: any?) | (m: list<> with (list & ~{ }), diag: any?, upper: any?) | (m: vec<...>, diag: any?, upper: any?) | (m: vec<> with (list & ~{ }), diag: any?, upper: any?) -> any)<>
timing: 3.47 s
source
as.dist.cl_dissimilarity <-
function(m, diag = FALSE, upper = FALSE)
{
y <- c(m)
## Fill non-inherited attributes with default values.
attributes(y) <- c(attributes(m)[c("Size", "Labels")],
Diag = diag, Upper = upper, call = match.call())
## (Note that as.dist.default() does not automatically add
## 'method'.)
class(y) <- "dist"
y
}
R/dissimilarity.R:487
[.cl_dissimilarity untypeabletyped
unbound variable (line 505)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any with { description: any, any }, i: any, j: any) -> any)<>
timing: 0.030 s
source
"[.cl_dissimilarity" <-
function(x, i, j)
{
y <- NextMethod("[")
if(!inherits(y, "cl_dissimilarity")) {
description <- attr(x, "description")
return(cl_cross_proximity(y, description = description,
class = "cl_cross_dissimilarity"))
}
y
}
R/dissimilarity.R:502
R/consensus.R
.cl_consensus_method_default skipped
error detail
Failure("Unsupported positional argument after a named one.")timing: 0.000 s
source
.cl_consensus_method_default <-
function(type)
{
switch(type, partition = "SE", hierarchy = "euclidean", NULL)
}
R/consensus.R:1089
cl_consensus untypeable
unbound variable (line 17)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.071 s
source
cl_consensus <-
function(x, method = NULL, weights = 1, control = list())
{
## <NOTE>
## Interfaces are a matter of taste.
## E.g., one might want to have a 'type' argument indication whether
## hard or soft partitions are sought. One could then do
## cl_consensus(x, method = "euclidean", type = "hard")
## to look for an optimal median (or least squares) hard partition
## (for euclidean dissimilarity).
## For us, "method" really indicates a certain algorithm, with its
## bells and whistles accessed via the 'control' argument.
## </NOTE>
clusterings <- as.cl_ensemble(x)
if(!length(clusterings))
stop("Cannot compute consensus of empty ensemble.")
weights <- rep_len(weights, length(clusterings))
if(any(weights < 0))
stop("Argument 'weights' has negative elements.")
if(!any(weights > 0))
stop("Argument 'weights' has no positive elements.")
if(!is.function(method)) {
if(!inherits(method, "cl_consensus_method")) {
## Get the method definition from the registry.
type <- .cl_ensemble_type(clusterings)
if(is.null(method))
method <- .cl_consensus_method_default(type)
method <- get_cl_consensus_method(method, type)
}
method <- method$definition
}
method(clusterings, weights, control)
}
R/consensus.R:3
.project_to_leading_columns untypeable
unbound variable (line 1104)
unbound: rowSums — a name the prelude does not declare
error detail
name: rowSums
timing: 0.078 s
source
.project_to_leading_columns <-
function(x, k)
{
## For a given matrix stochastic matrix x, return the stochastic
## matrix y which has columns from k+1 on all zero which is closest
## to x in the Frobenius distance.
y <- x[, seq_len(k), drop = FALSE]
y <- cbind(pmax(y + (1 - rowSums(y)) / k, 0),
matrix(0, nrow(y), ncol(x) - k))
## (Use the pmax to ensure that entries remain nonnegative.)
}
R/consensus.R:1097
.cl_consensus_partition_DWH untypeable
unbound variable (line 54)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 0.078 s
source
.cl_consensus_partition_DWH <-
function(clusterings, weights, control)
{
## <TODO>
## Could make things more efficient by subscripting on positive
## weights.
## (Note that this means control$order has to be subscripted as
## well.)
## </TODO>
max_n_of_classes <- max(sapply(clusterings, n_of_classes))
## Control parameters.
k <- control$k
if(is.null(k))
k <- max_n_of_classes
order <- control$order
if(is.null(order))
order <- sample(seq_along(clusterings))
clusterings <- clusterings[order]
weights <- weights[order]
k_max <- max(k, max_n_of_classes)
s <- weights / cumsum(weights)
s[is.na(s)] <- 0 # Division by zero ...
M <- cl_membership(clusterings[[1L]], k_max)
for(b in seq_along(clusterings)[-1L]) {
mem <- cl_membership(clusterings[[b]], k_max)
## Match classes from conforming memberships.
ind <- solve_LSAP(crossprod(M, mem), maximum = TRUE)
M <- (1 - s[b]) * M + s[b] * mem[, ind]
if(k < k_max)
M <- .project_to_leading_columns(M, k)
}
M <- .cl_membership_from_memberships(M[, seq_len(k), drop = FALSE], k)
as.cl_partition(M)
}
R/consensus.R:44
.l1_fit_M untypeabletimeout
unbound variable (line 315)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: timeout
timing: 0.991 s
source
.l1_fit_M <-
function(memberships, w, k)
{
## Determine stochastic matrix M with at most k leading nonzero
## columns such that
##
## \sum_b w_b \sum_{i,j} | m_{ij}(b) - m_{ij} | => min
##
## where the sum over j goes from 1 to k.
##
## Clearly, this can be done separately for each row, where we need
## to minimize
##
## \sum_b w_b \sum_j | y_j(b) - x_j | => min
##
## over all probability vectors x. Such problems can e.g. be solved
## via the following linear program:
##
## \sum_b \sum_j w_b e'(u(b) + v(b)) => min
##
## subject to
##
## u(1), v(1), ..., u(B), v(B), x >= 0
## x + u(b) - v(b) = y(b), b = 1, ..., B
## e'x = 1
##
## (where e = [1, ..., 1]).
##
## So we have one long vector z of "variables":
##
## z = [u(1)', v(1)', ..., u(B)', v(B)', x']'
##
## of length (2B + 1) k, with x the object of interest.
## Rather than providing a separate function for weighted L1 fitting
## of probability vectors we prefer doing "everything" at once, in
## order to avoid recomputing the coefficients and constraints of
## the associated linear program.
B <- length(memberships)
L <- (2 * B + 1) * k
## Set up associated linear program.
## Coefficients in the objective function.
objective_in <- c(rep(w, each = 2 * k), rep.int(0, k))
## Constraints.
constr_mat <- rbind(diag(1, L),
cbind(kronecker(diag(1, B),
cbind(diag(1, k),
diag(-1, k))),
kronecker(rep.int(1, B),
diag(1, k))),
c(rep.int(0, 2 * B * k), rep.int(1, k)))
constr_dir <- c(rep.int(">=", L), rep.int("==", B * k + 1L))
ind <- seq.int(from = 2 * B * k + 1L, length.out = k)
nr <- NROW(memberships[[1L]])
nc <- NCOL(memberships[[1L]])
M <- matrix(0, nrow = nr, ncol = k)
## Put the memberships into one big array so that we can get their
## rows more conveniently (and efficiently):
memberships <- array(unlist(memberships), c(nr, nc, B))
for(i in seq_len(nr)) {
out <- lpSolve::lp("min",
objective_in,
constr_mat,
constr_dir,
c(rep.int(0, L), memberships[i, seq_len(k), ], 1))
M[i, ] <- out$solution[ind]
}
## Add zero columns if necessary.
if(k < nc)
M <- cbind(M, matrix(0, nr, nc - k))
M
}
R/consensus.R:270
.random_stochastic_matrix untypeabletyped
unbound variable (line 266)
unbound: runif — a name the prelude does not declare
error detail
name: runif
gradual mode: typed
((n: <@"*", ...>, k: any) | (n: dbl<~@"*", ...>, k: dbl) -> any)<>
timing: 1.24 s
source
.random_stochastic_matrix <-
function(n, k)
{
M <- matrix(runif(n * k), n, k)
M / rowSums(M)
}
R/consensus.R:263
.cl_consensus_partition_AOS untypeabletimeout
unbound variable (line 129)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 0.687 s
source
.cl_consensus_partition_AOS <-
function(clusterings, weights, control,
type = c("SE", "HE", "SM", "HM"))
{
## The start of a general purpose optimizer for determining
## consensus partitions by minimizing
## \sum_b w_b d(M, M_b) ^ e
## = \sum_b \min_{P_b} w_b f(M, M_b P_b) ^ e
## for the special case where the criterion function is based on
## M and M_b P_b (i.e., column permutations of M_b), as opposed to
## the general case where d(M, M_b) = \min_{P_b} f(M, P_b, M_b)
## handled by .cl_consensus_partition_AOG().
##
## The AO ("alternative optimization") proceeds by alternatively
## matching the M_b to M by minimizing f(M, M_b P_b) over P_b, and
## fitting M by minimizing \sum_b w_b f(M, M_b P_b) ^ e for fixed
## matchings.
##
## Such a procedure requires three ingredients: a function for
## matching M_b to M (in fact simply replacing M_b by the matched
## M_b P_b); a function for fitting M to the \{M_b P_b\}, and a
## function for computing the value of the criterion function
## corresponding to this fit (so that one can stop if the relative
## improvement is small enough).
##
## For the time being, we only use this to determine soft and hard
## Euclidean least squares consensus partitions (soft and hard
## Euclidean means), so the interface does not yet reflect the
## generality of the approach (which would either pass the three
## functions, or even set up family objects encapsulating the three
## functions).
##
## This special case is provided for efficiency and convenience.
## Using the special form of the criterion function, we can simply
## always work memberships with the same maximal number of columns,
## and with the permuted \{ M_b P_b \}.
## For the time being ...
type <- match.arg(type)
w <- weights / sum(weights)
n <- n_of_objects(clusterings)
k_max <- max(sapply(clusterings, n_of_classes))
## Control parameters.
k <- control$k
if(is.null(k))
k <- k_max
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 100
nruns <- control$nruns
reltol <- control$reltol
if(is.null(reltol))
reltol <- sqrt(.Machine$double.eps)
start <- control$start
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
nruns <- length(start)
} else {
if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
start <- replicate(nruns,
.random_stochastic_matrix(n, k),
simplify = FALSE)
}
## The maximal (possible) number of classes in M and the \{ M_b \}.
k_all <- max(k, k_max)
value <-
switch(type,
SE = , HE = function(M, memberships, w) {
sum(w * sapply(memberships,
function(u) sum((u - M) ^ 2)))
},
SM = , HM = function(M, memberships, w) {
sum(w * sapply(memberships,
function(u) sum(abs(u - M))))
})
## Return the M[, ind] column permutation of M optimally matching N.
match_memberships <-
switch(type,
SE = , HE = function(M, N) {
M[, solve_LSAP(crossprod(N, M), maximum = TRUE),
drop = FALSE]
},
SM = , HM = function(M, N) {
M[, solve_LSAP(.cxdist(N, M, "manhattan")),
drop = FALSE]
})
## Function for fitting M to (fixed) memberships \{ M_b P_b \}.
## As we use a common number of columns for all membership matrices
## involved, we need to pass the desired 'k' ...
fit_M <-
switch(type,
SE = function(memberships, w, k) {
## Update M as \sum w_b M_b P_b.
M <- .weighted_sum_of_matrices(memberships, w, nrow(M))
## If k < k_all, "project" as indicated in Gordon &
## Vichi (2001), p. 238.
if(k < ncol(M))
M <- .project_to_leading_columns(M, k)
M
},
HE = , HM = function(memberships, w, k) {
## Compute M as \sum w_b M_b P_b.
M <- .weighted_sum_of_matrices(memberships, w, nrow(M))
## And compute a closest hard partition H(M) from
## that, using the first k columns of M.
ids <- max.col(M[ , seq_len(k), drop = FALSE])
.cl_membership_from_class_ids(ids, ncol(M))
},
SM = .l1_fit_M)
memberships <- lapply(clusterings, cl_membership, k_all)
V_opt <- Inf
M_opt <- NULL
for(run in seq_along(start)) {
if(verbose && (nruns > 1L))
message(gettextf("AOS run: %d", run))
M <- start[[run]]
if(k < k_all)
M <- cbind(M, matrix(0, nrow(M), k_all - k))
memberships <- lapply(memberships, match_memberships, M)
old_value <- value(M, memberships, w)
if(verbose)
message(gettextf("Iteration: 0 *** value: %g", old_value))
iter <- 1L
while(iter <= maxiter) {
## Fit M to the M_b P_b.
M <- fit_M(memberships, w, k)
## Match the \{ M_b P_b \} to M.
memberships <- lapply(memberships, match_memberships, M)
## Update value.
new_value <- value(M, memberships, w)
if(verbose)
message(gettextf("Iteration: %d *** value: %g",
iter, new_value))
if(abs(old_value - new_value)
< reltol * (abs(old_value) + reltol))
break
old_value <- new_value
iter <- iter + 1L
}
if(new_value < V_opt) {
converged <- (iter <= maxiter)
V_opt <- new_value
M_opt <- M
}
if(verbose)
message(gettextf("Minimum: %g", V_opt))
}
M <- .stochastify(M_opt)
rownames(M) <- rownames(memberships[[1L]])
meta <- list(objval = value(M, memberships, w),
converged = converged)
M <- .cl_membership_from_memberships(M[, seq_len(k), drop = FALSE],
k, meta)
as.cl_partition(M)
}
R/consensus.R:88
.cl_consensus_partition_soft_euclidean untypeabletyped
unbound variable (line 357)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_soft_euclidean <-
function(clusterings, weights, control)
.cl_consensus_partition_AOS(clusterings, weights, control, "SE")
R/consensus.R:355
.cl_consensus_partition_hard_euclidean untypeabletyped
unbound variable (line 363)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_hard_euclidean <-
function(clusterings, weights, control)
.cl_consensus_partition_AOS(clusterings, weights, control, "HE")
R/consensus.R:361
.cl_consensus_partition_soft_manhattan untypeabletyped
unbound variable (line 369)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_soft_manhattan <-
function(clusterings, weights, control)
.cl_consensus_partition_AOS(clusterings, weights, control, "SM")
R/consensus.R:367
.cl_consensus_partition_hard_manhattan untypeabletyped
unbound variable (line 375)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_hard_manhattan <-
function(clusterings, weights, control)
.cl_consensus_partition_AOS(clusterings, weights, control, "HM")
R/consensus.R:373
.cscale untypeable
untypeable application of base::* (line 1136)
error detail
argument: @(v('I10680), 'A)
failing call: base::*(as.raw(0), new.env())timing: 0.535 s
source
.cscale <-
function(A, x)
{
## Scale the columns of matrix A by the elements of vector x.
## Formally, A %*% diag(x), but faster.
## Could also use sweep(A, 2, x, "*")
rep(x, each = nrow(A)) * A
}
R/consensus.R:1134
.n_of_nonzero_columns untypeabletyped
unbound variable (line 1127)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: any) -> any)<>
timing: 0.005 s
source
.n_of_nonzero_columns <-
function(x)
sum(colSums(x) > 0)
R/consensus.R:1125
.cl_consensus_partition_AOG untypeabletimeout
unbound variable (line 412)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 1.97 s
source
.cl_consensus_partition_AOG <-
function(clusterings, weights, control, type = c("GV1"))
{
## The start of a general purpose optimizer for determining
## consensus partitions by minimizing
## \sum_b w_b d(M, M_b) ^ p
## = \sum_b \min_{P_b} w_b f(M, M_b, P_b) ^ e
## for general dissimilarity matrices which involve class matching
## via permutation matrices P_b.
##
## The AO ("Alternative Optimization") proceeds by alternating
## between determining the optimal permutations P_b by minimizing
## f(M, M_b, P_b)
## for fixed M, and fitting M by minimizing
## \sum_b w_b f(M, M_b, P_b) ^ e
## for fixed \{ P_b \}.
##
## We encapsulate this into functions fit_P() and fit_M() (and a
## value() function for the criterion function to be minimized with
## respect to both M and \{ P_b \}, even though the current
## interface does not yet reflect the generality of the approach.
##
## Note that rather than passing on information about the numbers of
## classes (e.g., needed for GV1) and representing all involved
## membership matrices with the same maximal number of columns, we
## use "minimal" representations with no dummy classes (strictly
## speaking, with the possible exception of M, for which the given k
## is used).
## For the time being ...
type <- match.arg(type)
w <- weights / sum(weights)
n <- n_of_objects(clusterings)
k_max <- max(sapply(clusterings, n_of_classes))
## Control parameters.
k <- control$k
if(is.null(k))
k <- k_max
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 100L
nruns <- control$nruns
reltol <- control$reltol
if(is.null(reltol))
reltol <- sqrt(.Machine$double.eps)
start <- control$start
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
nruns <- length(start)
} else {
if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
start <- replicate(nruns,
.random_stochastic_matrix(n, k),
simplify = FALSE)
}
## <NOTE>
## For the given memberships, we can simply use ncol() in the
## computations (rather than n_of_classes(), because we used
## cl_membership() to create them. For M, the number of classes
## could be smaller than the given k "target".
## </NOTE>
value <- function(M, permutations, memberships, w) {
k <- .n_of_nonzero_columns(M)
d <- function(u, p) {
## Compute the squared GV1 dissimilarity between M and u
## based on the M->u class matching p.
nc_u <- ncol(u)
if(nc_u == k) {
## Simple case: all classes are matched.
sum((u[, p] - M) ^ 2)
}
else {
## Only include the matched non-dummy classes of M ..
ind <- seq_len(k)
## ... which are matched to non-dummy classes of u.
ind <- ind[p[ind] <= nc_u]
sum((u[, p[ind]] - M[, ind]) ^ 2)
}
}
sum(w * mapply(d, memberships, permutations))
}
fit_P <- function(u, M) {
## Return a permutation representing a GV1 optimal matching of
## the columns of M to the columns of u (note the order of the
## arguments), using a minimal number of dummy classes (i.e., p
## has max(.n_of_nonzero_columns(M), n_of_classes(u)) entries).
## See also .cl_dissimilarity_partition_GV1().
C <- outer(colSums(M ^ 2), colSums(u ^ 2), `+`) -
2 * crossprod(M, u)
nc_M <- .n_of_nonzero_columns(M)
nc_u <- ncol(u)
## (See above for ncol() vs n_of_classes().)
if(nc_M < nc_u)
C <- rbind(C, matrix(0, nrow = nc_u - nc_M, ncol = nc_u))
else if(nc_M > nc_u)
C <- cbind(C, matrix(0, nrow = nc_M, ncol = nc_M - nc_u))
solve_LSAP(C)
}
fit_M <- function(permutations, memberships, w) {
## Here comes the trickiest part ...
##
## In general, M = [m_{iq}] is determined as follows.
## Write value(M, permutations, memberships, w) as
## \sum_b \sum_i \sum_{p=1}^{k_b} \sum_{q=1}^k
## w_b (u_{ip}(b) - m_{iq})^2 x_{pq}(b)
## where U(b) and X(b) are the b-th membership matrix and the
## permutation matrix representing the M->U(b) non-dummy class
## matching (as always, note the order of the arguments).
##
## Let
## \beta_{iq} = \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b) x_{pq}(b)
## \alpha_q = \sum_b \sum_{p=1}^{k_b} w_b x_{pq}(b)
## and
## \bar{m}_{iq} =
## \cases{\beta_{iq}/\alpha_q, & $\alpha_q > 0$ \cr
## 0 & otherwise}.
## Then, as the cross-product terms cancel out, the value
## function rewrites as
## \sum_b \sum_i \sum_{p=1}^{k_b} \sum_{q=1}^k
## w_b (u_{ip}(b) - \bar{m}_{iq})^2 x_{pq}(b)
## + \sum_i \sum_q \alpha_q (\bar{m}_{iq} - m_{iq}) ^ 2,
## where the first term is a constant, and the minimum is found
## by solving
## \sum_q \alpha_q (\bar{m}_{iq} - m_{iq}) ^ 2 => min!
## s.t.
## m_{i1}, ..., m_{ik} >= 0, \sum_{iq} m_{iq} = 1.
##
## We can distinguish three cases.
## A. If S_i = \sum_q \bar{m}_{iq} = 1, things are trivial.
## B. If S_i = \sum_q \bar{m}_{iq} < 1.
## B1. If some \alpha_q are zero, then we can choose
## m_{iq} = \bar{m}_{iq} for those q with \alpha_q = 0;
## m_{iq} = 1 / number of zero \alpha's, otherwise.
## B2. If all \alpha_q are positive, we can simply
## equidistribute 1 - S_i over all classes as written
## in G&V.
## C. If S_i > 1, things are not so clear (as equidistributing
## will typically result in violations of the non-negativity
## constraint). We currently revert to using solve.QP() from
## package quadprog, as constrOptim() already failed in very
## simple test cases.
##
## Now consider \sum_{p=1}^{k_b} x_{pq}(b). If k <= k_b for all
## b, all M classes from 1 to k are matched to one of the k_b
## classes in U(b), hence the sum and also \alpha_q are one.
## But then
## \sum_q \bar{m}_{iq}
## = \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b) x_{pq}(b)
## <= \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b)
## = 1
## with equality if k = k_b for all b. I.e.,
## * If k = \min_b k_b = \max k_b, we are in case A.
## * If k <= \min_b k_b, we are in case B2.
## And it makes sense to handle these cases explicitly for
## efficiency reasons.
## And now for something completely different ... the code.
k <- .n_of_nonzero_columns(M)
nr_M <- nrow(M)
nc_M <- ncol(M)
nc_memberships <- sapply(memberships, ncol)
if(k <= min(nc_memberships)) {
## Compute the weighted means \bar{M}.
M <- .weighted_sum_of_matrices(mapply(function(u, p)
u[ , p[seq_len(k)]],
memberships,
permutations,
SIMPLIFY = FALSE),
w, nr_M)
## And add dummy classes if necessary.
if(k < nc_M)
M <- cbind(M, matrix(0, nr_M, nc_M - k))
## If we always got the same number of classes, we are
## done. Otherwise, equidistribute ...
if(k < max(nc_memberships))
R/consensus.R:379
.cl_consensus_partition_GV1 untypeabletyped
unbound variable (line 711)
unbound: .cl_consensus_partition_AOG — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOG
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_GV1 <-
function(clusterings, weights, control)
.cl_consensus_partition_AOG(clusterings, weights, control, "GV1")
R/consensus.R:709
.make_penalty_function_membership untypeabletyped
unbound variable (line 1149)
unbound: pmin — a name the prelude does not declare
error detail
name: pmin
gradual mode: typed
((nr: dbl1, nc: any) -> ((m: vec) -> any)<>)<>
timing: 0.023 s
source
.make_penalty_function_membership <-
function(nr, nc)
function(m) {
sum(pmin(m, 0) ^ 2) + sum((rowSums(matrix(m, nr)) - 1) ^ 2)
}
R/consensus.R:1146
.make_penalty_gradient_membership untypeabletyped
unbound variable (line 1157)
unbound: pmin — a name the prelude does not declare
error detail
name: pmin
gradual mode: typed
((nr: dbl1, nc: any) -> ((m: vec) -> any)<>)<>
timing: 0.022 s
source
.make_penalty_gradient_membership <-
function(nr, nc)
function(m) {
2 * (pmin(m, 0) + rep.int(rowSums(matrix(m, nr)) - 1, nc))
}
R/consensus.R:1154
.cl_consensus_partition_GV3 untypeabletimeout
unbound variable (line 723)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 0.145 s
source
.cl_consensus_partition_GV3 <-
function(clusterings, weights, control)
{
## Use a SUMT to solve
## \| Y - M M' \|_F^2 => min
## where M is a membership matrix and Y = \sum_b w_b M_b M_b'.
n <- n_of_objects(clusterings)
max_n_of_classes <- max(sapply(clusterings, n_of_classes))
## Control parameters:
## k,
k <- control$k
if(is.null(k))
k <- max_n_of_classes
## nruns,
nruns <- control$nruns
## start.
start <- control$start
w <- weights / sum(weights)
comemberships <-
lapply(clusterings, function(x) {
## No need to force a common k here.
tcrossprod(cl_membership(x))
})
Y <- .weighted_sum_of_matrices(comemberships, w, n)
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else {
if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
e <- eigen(Y, symmetric = TRUE)
## Use M <- U_k \lambda_k^{1/2}, or random perturbations
## thereof.
M <- e$vectors[, seq_len(k), drop = FALSE] *
rep(sqrt(e$values[seq_len(k)]), each = n)
m <- c(M)
start <- c(list(m),
replicate(nruns - 1L,
m + rnorm(length(m), sd = sd(m) / sqrt(3)),
simplify = FALSE))
}
y <- c(Y)
L <- function(m) sum((y - tcrossprod(matrix(m, n))) ^ 2)
P <- .make_penalty_function_membership(n, k)
grad_L <- function(m) {
M <- matrix(m, n)
4 * c((tcrossprod(M) - Y) %*% M)
}
grad_P <- .make_penalty_gradient_membership(n, k)
out <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))
M <- .stochastify(matrix(out$x, n))
rownames(M) <- rownames(cl_membership(clusterings[[1L]]))
meta <- list(objval = L(c(M)))
M <- .cl_membership_from_memberships(M, k, meta)
as.cl_partition(M)
}
R/consensus.R:716
.cl_consensus_partition_soft_symdiff untypeabletimeout
unbound variable (line 825)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: timeout
timing: 1.13 s
source
.cl_consensus_partition_soft_symdiff <-
function(clusterings, weights, control)
{
## Use a SUMT to solve
## \sum_b w_b \sum_{ij} | c_{ij}(b) - c_{ij} | => min
## where C(b) = comembership(M(b)) and C = comembership(M) and M is
## a membership matrix.
## Control parameters:
## gradient,
gradient <- control$gradient
if(is.null(gradient))
gradient <- TRUE
## k,
k <- control$k
## nruns,
nruns <- control$nruns
## start.
start <- control$start
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
max_n_of_classes <- max(sapply(clusterings, n_of_classes))
if(is.null(k))
k <- max_n_of_classes
B <- length(clusterings)
n <- n_of_objects(clusterings)
w <- weights / sum(weights)
comemberships <-
lapply(clusterings, function(x) {
## No need to force a common k here.
tcrossprod(cl_membership(x))
})
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else {
if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
## Try using a rank k "root" of the weighted median of the
## comemberships as starting value.
Y <- apply(array(unlist(comemberships), c(n, n, B)), c(1, 2),
weighted_median, w)
e <- eigen(Y, symmetric = TRUE)
## Use M <- U_k \lambda_k^{1/2}, or random perturbations
## thereof.
M <- e$vectors[, seq_len(k), drop = FALSE] *
rep(sqrt(e$values[seq_len(k)]), each = n)
m <- c(M)
start <- c(list(m),
replicate(nruns - 1L,
m + rnorm(length(m), sd = sd(m) / sqrt(3)),
simplify = FALSE))
}
L <- function(m) {
M <- matrix(m, n)
C_M <- tcrossprod(M)
## Note that here (as opposed to hard/symdiff) we take soft
## partitions as is without replacing them by their closest hard
## partitions.
sum(w * sapply(comemberships,
function(C) sum(abs(C_M - C))))
}
P <- .make_penalty_function_membership(n, k)
if(gradient) {
grad_L <- function(m) {
M <- matrix(m, n)
C_M <- tcrossprod(M)
.weighted_sum_of_matrices(lapply(comemberships,
function(C)
2 * sign(C_M - C) %*% M),
w, n)
}
grad_P <- .make_penalty_gradient_membership(n, k)
}
else
grad_L <- grad_P <- NULL
out <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))
M <- .stochastify(matrix(out$x, n))
rownames(M) <- rownames(cl_membership(clusterings[[1L]]))
meta <- list(objval = L(c(M)))
M <- .cl_membership_from_memberships(M, k, meta)
as.cl_partition(M)
}
R/consensus.R:794
.cl_consensus_partition_hard_symdiff untypeabletyped
unbound variable (line 920)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((clusterings: list, weights: any, control: { k: null, control: list, any }) | (clusterings: list, weights: any, control: { k: ~null, control: list, any }) | (clusterings: vec, weights: any, control: { k: null, control: list, any }) | (clusterings: vec, weights: any, control: { k: ~null, control: list, any }) -> any)<>
timing: 0.050 s
source
.cl_consensus_partition_hard_symdiff <-
function(clusterings, weights, control)
{
## <NOTE>
## This is mostly duplicated from relations.
## Once this is on CRAN, we could consider having clue suggest
## relations ...
## </NOTE>
comemberships <-
lapply(clusterings,
function(x) {
## Here, we always turn possibly soft partitions to
## their closest hard partitions.
ids <- cl_class_ids(x)
outer(ids, ids, `==`)
## (Simpler than using tcrossprod() on
## cl_membership().)
})
## Could also create a relation ensemble from the comemberships and
## call relation_consensus().
B <- relations:::.make_fit_relation_symdiff_B(comemberships,
weights)
k <- control$k
control <- control$control
## Note that currently we provide no support for finding *all*
## consensus partitions (but allow for specifying the solver).
control$all <- FALSE
I <- if(!is.null(k)) {
## <NOTE>
## We could actually get the memberships directly in this case.
relations:::fit_relation_LP_E_k(B, k, control)
## </NOTE>
}
else
relations:::fit_relation_LP(B, "E", control)
ids <- relations:::get_class_ids_from_incidence(I)
names(ids) <- cl_object_names(clusterings)
as.cl_hard_partition(ids)
}
R/consensus.R:906
.cl_consensus_hierarchy_cophenetic untypeabletyped
unbound variable (line 960)
unbound: ls_fit_ultrametric — one of the package’s own names, itself untyped
error detail
name: ls_fit_ultrametric
gradual mode: typed
((clusterings: any, weights: any, control: list | null) -> any)<>
timing: 0.056 s
source
.cl_consensus_hierarchy_cophenetic <-
function(clusterings, weights, control)
{
## d <- .weighted_mean_of_object_dissimilarities(clusterings, weights)
## Alternatively:
## as.cl_dendrogram(ls_fit_ultrametric(d, control = control))
control <- c(list(weights = weights), control)
as.cl_dendrogram(ls_fit_ultrametric(clusterings, control = control))
}
R/consensus.R:953
.cl_consensus_hierarchy_manhattan untypeabletimeout
unbound variable (line 991)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: timeout
timing: 4.31 s
source
.cl_consensus_hierarchy_manhattan <-
function(clusterings, weights, control)
{
## Control parameters:
## gradient,
gradient <- control$gradient
if(is.null(gradient))
gradient <- TRUE
## nruns,
nruns <- control$nruns
## start.
start <- control$start
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
w <- weights / sum(weights)
B <- length(clusterings)
ultrametrics <- lapply(clusterings, cl_ultrametric)
if(B == 1L)
return(as.cl_dendrogram(ultrametrics[[1L]]))
n <- n_of_objects(ultrametrics[[1L]])
labels <- cl_object_names(ultrametrics[[1L]])
## We need to do
##
## \sum_b w_b \sum_{i,j} | u_{ij}(b) - u_{ij} | => min
##
## over all ultrametrics u. Let's use a SUMT (for which "gradients"
## can optionally be switched off) ...
L <- function(d) {
sum(w * sapply(ultrametrics, function(u) sum(abs(u - d))))
## Could also do something like
## sum(w * sapply(ultrametrics, cl_dissimilarity, d,
## "manhattan"))
}
P <- .make_penalty_function_ultrametric(n)
if(gradient) {
grad_L <- function(d) {
## "Gradient" is \sum_b w_b sign(d - u(b)).
.weighted_sum_of_vectors(lapply(ultrametrics,
function(u) sign(d - u)),
w)
}
grad_P <- .make_penalty_gradient_ultrametric(n)
} else
grad_L <- grad_P <- NULL
if(is.null(start)) {
## Initialize by "random shaking" of the weighted median of the
## ultrametrics. Any better ideas?
## <NOTE>
## Using var(x) / 3 is really L2 ...
## </NOTE>
x <- apply(matrix(unlist(ultrametrics), ncol = B), 1,
weighted_median, w)
start <- replicate(nruns,
x + rnorm(length(x), sd = sd(x) / sqrt(3)),
simplify = FALSE)
}
out <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))
d <- .ultrametrify(out$x)
meta <- list(objval = L(d))
d <- .cl_ultrametric_from_veclh(d, n, labels, meta)
as.cl_dendrogram(d)
}
R/consensus.R:965
.cl_consensus_hierarchy_majority typed empty return any: clusterings
((clusterings: any, weights: dbl<@"/", ...>, control: { p: ~((DBL | INT) | null), any }) | (clusterings: any, weights: dbl<~@"/", ...>, control: { p: ~((DBL | INT) | null), any }) -> empty)<>
timing: 5.03 s
source
.cl_consensus_hierarchy_majority <-
function(clusterings, weights, control)
{
w <- weights / sum(weights)
p <- control$p
if(is.null(p))
p <- 1 / 2
else if(!is.numeric(p) || (length(p) != 1) || (p < 1 / 2) || (p > 1))
stop("Parameter 'p' must be in [1/2, 1].")
classes <- lapply(clusterings, cl_classes)
all_classes <- unique(unlist(classes, recursive = FALSE))
gamma <- double(length = length(all_classes))
for(i in seq_along(classes))
gamma <- gamma + w[i] * !is.na(match(all_classes, classes[[i]]))
## Rescale to [0, 1].
gamma <- gamma / max(gamma)
maj_classes <- if(p == 1) {
## Strict consensus tree.
all_classes[gamma == 1]
}
else
all_classes[gamma > p]
attr(maj_classes, "labels") <- attr(classes[[1L]], "labels")
## <FIXME>
## Stop auto-coercing that to dendrograms once we have suitable ways
## of representing n-trees.
as.cl_hierarchy(.cl_ultrametric_from_classes(maj_classes))
## </FIXME>
}
R/consensus.R:1051
.make_X_from_p untypeabletyped
unbound variable (line 1117)
unbound: cbind — a name the prelude does not declare
error detail
name: cbind
gradual mode: typed
((p: <@"[", ...>) | (p: list<~@"[", ...>) | (p: vec<~@"[", ...>) -> any)<>
timing: 0.064 s
source
.make_X_from_p <-
function(p) {
## X matrix corresponding to permutation p as needed for the AO
## algorithms. I.e., x_{ij} = 1 iff j->p(j)=i.
X <- matrix(0, length(p), length(p))
i <- seq_along(p)
X[cbind(p[i], i)] <- 1
X
}
R/consensus.R:1111
R/partition.R
n_of_classes untypeabletyped
unbound variable (line 14)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
n_of_classes <-
function(x)
UseMethod("n_of_classes")
R/partition.R:12
cl_class_ids untypeabletyped
unbound variable (line 72)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids <-
function(x)
UseMethod("cl_class_ids")
R/partition.R:70
n_of_classes.default untypeabletyped
unbound variable (line 19)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.003 s
source
n_of_classes.default <-
function(x)
length(unique(cl_class_ids(x)))
R/partition.R:17
n_of_classes.kmeans untypeabletyped
unbound variable (line 22)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.kmeans <- n_of_classes.default
R/partition.R:22
n_of_classes.fanny untypeabletyped
unbound variable (line 28)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.016 s
source
n_of_classes.fanny <-
function(x)
sum(colSums(x$membership, na.rm = TRUE) > 0)
R/partition.R:26
n_of_classes.partition untypeabletyped
unbound variable (line 29)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.partition <- n_of_classes.default
R/partition.R:29
n_of_classes.cclust untypeabletyped
unbound variable (line 32)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.cclust <- n_of_classes.default
R/partition.R:32
n_of_classes.fclust untypeabletyped
unbound variable (line 35)
unbound: n_of_classes.fanny — one of the package’s own names, itself untyped
error detail
name: n_of_classes.fanny
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.000 s
source
n_of_classes.fclust <- n_of_classes.fanny
R/partition.R:35
n_of_classes.cshell untypeabletyped
unbound variable (line 37)
unbound: n_of_classes.fanny — one of the package’s own names, itself untyped
error detail
name: n_of_classes.fanny
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.000 s
source
n_of_classes.cshell <- n_of_classes.fanny
R/partition.R:37
n_of_classes.bclust untypeabletyped
unbound variable (line 39)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.bclust <- n_of_classes.default
R/partition.R:39
n_of_classes.Mclust untypeabletyped
unbound variable (line 42)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.Mclust <- n_of_classes.default
R/partition.R:42
n_of_classes.cl_membership typed accepts outside
∀'a. ((x: any with { n_of_classes: 'a, any }) -> 'a)<>
timing: 0.025 s
fuzzing: 20 inside (20 ok) · 8 outside (2 rejected, 6 accepted)
type drawn from: ((x: any with { n_of_classes: 'I11911, any }) -> 'I11911)<>
Accepted outside the domain x: 6
| parameter | change | call | returned |
|---|
| x | attr:drop:n_of_classes | n_of_classes.cl_membership("x" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })) | null |
| x | kind:env | n_of_classes.cl_membership("x" = new.env()) | null |
| x | kind:fun | n_of_classes.cl_membership(function(...) NULL) | null |
| x | kind:sym | n_of_classes.cl_membership("x" = as.name("x")) | null |
| x | wrap | n_of_classes.cl_membership(list(structure(complex(real = 0, imaginary = 0), "n_of_classes" = ""))) | null |
| x | wrap | n_of_classes.cl_membership(list(structure(list(NULL, NULL), "n_of_classes" = NULL))) | null |
source
n_of_classes.cl_membership <-
function(x)
attr(x, "n_of_classes")
R/partition.R:45
n_of_classes.pclust untypeabletyped
unbound variable (line 53)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: { membership: any, any }) -> INT1<>)<>
timing: 0.032 s
source
n_of_classes.pclust <-
function(x)
{
if(is.null(m <- x$membership))
length(unique(cl_class_ids(x)))
else
sum(colSums(m, na.rm = TRUE) > 0)
}
R/partition.R:49
n_of_classes.cl_partition untypeabletyped
unbound variable (line 60)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.010 s
source
n_of_classes.cl_partition <-
function(x)
n_of_classes(.get_representation(x))
R/partition.R:58
cl_class_ids.default typed empty return any: x
((x: any) -> empty)<>
timing: 0.005 s
source
cl_class_ids.default <-
function(x)
{
stop("Cannot infer class ids from given object.")
}
R/partition.R:75
as.cl_class_ids untypeabletyped
unbound variable (line 198)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
gradual mode: typed
((x: <...>) -> any)<>
timing: 0.009 s
source
as.cl_class_ids <-
function(x)
{
## For the time being, handle only "raw" class ids.
## Maybe add methods handling factors lateron (if necessary).
## <NOTE>
## This could also be used to canonicalize returned class ids
## according to the docs (vector of integers with the class ids),
## using someting like
## match(ids, unique(ids))
## </NOTE>
.structure(unclass(x), class = "cl_class_ids")
}
R/partition.R:187
cl_class_ids.kmeans untypeabletyped
unbound variable (line 84)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.kmeans <-
function(x)
as.cl_class_ids(x$cluster)
R/partition.R:82
cl_class_ids.partition untypeabletyped
unbound variable (line 90)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { clustering: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.partition <-
function(x)
as.cl_class_ids(x$clustering)
R/partition.R:88
cl_class_ids.Weka_clusterer untypeabletyped
unbound variable (line 96)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { class_ids: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.Weka_clusterer <-
function(x)
as.cl_class_ids(x$class_ids)
R/partition.R:94
cl_class_ids.ccfkms untypeabletyped
unbound variable (line 101)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: { cl: any, any }) -> any)<>
timing: 0.012 s
source
cl_class_ids.ccfkms <-
function(x)
as.cl_class_ids(as.vector(x$cl))
R/partition.R:99
cl_class_ids.rock untypeabletyped
unbound variable (line 105)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: { cl: any, any }) -> any)<>
timing: 0.012 s
source
cl_class_ids.rock <-
function(x)
as.cl_class_ids(as.vector(x$cl))
R/partition.R:103
cl_class_ids.cclust untypeabletyped
unbound variable (line 108)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cclust <- cl_class_ids.kmeans
R/partition.R:108
cl_class_ids.fclust untypeabletyped
unbound variable (line 111)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.fclust <- cl_class_ids.kmeans
R/partition.R:111
cl_class_ids.cshell untypeabletyped
unbound variable (line 113)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cshell <- cl_class_ids.kmeans
R/partition.R:113
cl_class_ids.bclust untypeabletyped
unbound variable (line 115)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.bclust <- cl_class_ids.kmeans
R/partition.R:115
cl_class_ids.kcca untypeabletyped
unbound variable (line 126)
unbound: modeltools::clusters — a name the prelude does not declare
error detail
name: modeltools::clusters
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.kcca <-
function(x)
as.cl_class_ids(modeltools::clusters(x))
R/partition.R:124
cl_class_ids.flexmix untypeabletyped
unbound variable (line 136)
unbound: modeltools::clusters — a name the prelude does not declare
error detail
name: modeltools::clusters
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.flexmix <-
function(x)
as.cl_class_ids(modeltools::clusters(x))
R/partition.R:134
cl_class_ids.specc untypeabletyped
unbound variable (line 144)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: <...>) -> any)<>
timing: 0.009 s
source
cl_class_ids.specc <-
function(x)
{
tmp <- unclass(x)
as.cl_class_ids(.structure(as.vector(tmp), names = names(tmp)))
}
R/partition.R:140
cl_class_ids.Mclust untypeabletyped
unbound variable (line 150)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { classification: <...>, any }) -> any)<>
timing: 0.012 s
source
cl_class_ids.Mclust <-
function(x)
as.cl_class_ids(x$classification)
R/partition.R:148
cl_class_ids.relation untypeabletyped
unbound variable (line 155)
unbound: relations::relation_class_ids — a name the prelude does not declare
error detail
name: relations::relation_class_ids
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.relation <-
function(x)
as.cl_class_ids(relations::relation_class_ids(x))
R/partition.R:153
cl_class_ids.cl_class_ids typed fuzz ok
∀'a. (x: 'a) -> 'a
timing: 0.006 s
fuzzing: 20 inside (20 ok) · 8 outside (8 rejected)
type drawn from: (x: 'I12044) -> 'I12044
source
cl_class_ids.cl_class_ids <- identity
R/partition.R:158
cl_class_ids.cl_membership untypeabletyped
unbound variable (line 162)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
cl_class_ids.cl_membership <-
function(x)
as.cl_class_ids(.structure(max.col(x), names = rownames(x)))
R/partition.R:160
cl_class_ids.cl_pam untypeabletyped
unbound variable (line 166)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cl_pam <- cl_class_ids.kmeans
R/partition.R:166
cl_class_ids.cl_partition_by_class_ids typed accepts outside
∀'a. ((x: { .Data: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { .Data: 'I12059, any }) -> 'I12059)<>
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | kind:lang | cl_class_ids.cl_partition_by_class_ids(quote(f(x))) | null |
source
cl_class_ids.cl_partition_by_class_ids <-
function(x)
.get_representation(x)
R/partition.R:168
cl_class_ids.kmedoids untypeabletyped
unbound variable (line 172)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.kmedoids <- cl_class_ids.kmeans
R/partition.R:172
cl_class_ids.pclust untypeabletyped
unbound variable (line 174)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.pclust <- cl_class_ids.kmeans
R/partition.R:174
cl_class_ids.cl_partition untypeabletyped
unbound variable (line 178)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.cl_partition <-
function(x)
cl_class_ids(.get_representation(x))
R/partition.R:176
cl_class_ids.movMF untypeabletyped
unbound variable (line 183)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: { P: any, any }) -> any)<>
timing: 0.012 s
source
cl_class_ids.movMF <-
function(x)
as.cl_class_ids(max.col(x$P))
R/partition.R:181
print.cl_class_ids untypeabletyped
unbound variable (line 206)
unbound: writeLines — a name the prelude does not declare
error detail
name: writeLines
gradual mode: typed
∀'a. ((x: 'a & <...>, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_class_ids <-
function(x, ...)
{
writeLines("Class ids:")
print(unclass(x), ...)
invisible(x)
}
R/partition.R:203
cl_class_labels untypeabletyped
unbound variable (line 215)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_labels <-
function(x)
UseMethod("cl_class_labels")
R/partition.R:213
is.cl_partition untypeabletyped
unbound variable (line 225)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_partition <-
function(x)
UseMethod("is.cl_partition")
R/partition.R:223
is.cl_partition.default typed any: x accepts outside
((x: any) -> ff<>)<>
timing: 0.004 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.default() | ff<> with { } |
source
is.cl_partition.default <- .false
R/partition.R:228
is.cl_partition.kmeans typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 6 outside (5 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.kmeans() | tt<> with { } |
source
is.cl_partition.kmeans <- .true
R/partition.R:231
is.cl_partition.partition typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.partition() | tt<> with { } |
source
is.cl_partition.partition <- .true
R/partition.R:235
is.cl_partition.Weka_clusterer typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 5 inside (5 ok) · 6 outside (5 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.Weka_clusterer() | tt<> with { } |
source
is.cl_partition.Weka_clusterer <- .true
R/partition.R:241
is.cl_partition.ccfkms typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.ccfkms() | tt<> with { } |
source
is.cl_partition.ccfkms <- .true
R/partition.R:244
is.cl_partition.rock typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.rock() | tt<> with { } |
source
is.cl_partition.rock <- .true
R/partition.R:246
is.cl_partition.cclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.cclust() | tt<> with { } |
source
is.cl_partition.cclust <- .true
R/partition.R:249
is.cl_partition.fclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 6 outside (5 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.fclust() | tt<> with { } |
source
is.cl_partition.fclust <- .true
R/partition.R:252
is.cl_partition.cshell typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.cshell() | tt<> with { } |
source
is.cl_partition.cshell <- .true
R/partition.R:254
is.cl_partition.bclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.bclust() | tt<> with { } |
source
is.cl_partition.bclust <- .true
R/partition.R:256
is.cl_partition.kcca typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.kcca() | tt<> with { } |
source
is.cl_partition.kcca <- .true
R/partition.R:260
is.cl_partition.flexmix typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.flexmix() | tt<> with { } |
source
is.cl_partition.flexmix <- .true
R/partition.R:263
is.cl_partition.specc typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.specc() | tt<> with { } |
source
is.cl_partition.specc <- .true
R/partition.R:267
is.cl_partition.Mclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.Mclust() | tt<> with { } |
source
is.cl_partition.Mclust <- .true
R/partition.R:270
is.cl_partition.cl_partition typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.cl_partition() | tt<> with { } |
source
is.cl_partition.cl_partition <- .true
R/partition.R:275
is.cl_partition.kmedoids typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.kmedoids() | tt<> with { } |
source
is.cl_partition.kmedoids <- .true
R/partition.R:277
is.cl_partition.pclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.pclust() | tt<> with { } |
source
is.cl_partition.pclust <- .true
R/partition.R:279
is.cl_partition.movMF typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 2 outside (1 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_partition.movMF() | tt<> with { } |
source
is.cl_partition.movMF <- .true
R/partition.R:282
.cl_partition_classes typed
"cl_partition"<>
timing: 0.002 s
source
.cl_partition_classes <- "cl_partition"
R/partition.R:289
cl_partition_by_memberships untypeabletyped
unbound variable (line 440)
unbound: rowSums — a name the prelude does not declare
error detail
name: rowSums
gradual mode: typed
((x: vec, labels: any?) -> any)<>
timing: 0.146 s
source
cl_partition_by_memberships <-
function(x, labels = NULL)
{
if(!is.matrix(x)
|| any(x < 0, na.rm = TRUE)
|| any(x > 1, na.rm = TRUE))
stop("Not a valid membership matrix.")
## Be nice.
x <- x / rowSums(x, na.rm = TRUE)
## (Note that this does not imply all(rowSums(x) == 1). If we
## wanted to test for this, something like
## .is_stochastic_matrix <- function(x)
## identical(all.equal(rowSums(x), rep(1, nrow(x))), TRUE))
## should do.)
if(is.null(rownames(x)))
rownames(x) <- labels
.make_container(as.cl_membership(x),
c("cl_partition_by_memberships",
.cl_partition_classes),
list(n_of_objects = nrow(x)))
}
R/partition.R:432
as.cl_partition untypeable
unbound variable (line 294)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
timing: 0.028 s
source
as.cl_partition <-
function(x)
{
if(is.cl_partition(x)) {
if(!inherits(x, "cl_partition"))
.make_container(x, .cl_partition_classes)
else
x
}
else
cl_partition_by_memberships(as.cl_membership(x))
}
R/partition.R:291
print.cl_partition untypeabletyped
unbound variable (line 308)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.005 s
source
print.cl_partition <-
function(x, ...)
.print_container(x, "cl_partition", ...)
R/partition.R:306
print.cl_partition_by_class_ids untypeabletyped
unbound variable (line 316)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_partition_by_class_ids <-
function(x, ...)
{
writeLines(gettextf("A hard partition of %d objects.",
n_of_objects(x)))
print(cl_class_ids(x), ...)
invisible(x)
}
R/partition.R:312
print.cl_partition_by_memberships untypeabletyped
unbound variable (line 327)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.005 s
source
print.cl_partition_by_memberships <-
function(x, ...)
{
writeLines(gettextf("A partition of %d objects.",
n_of_objects(x)))
print(cl_membership(x), ...)
invisible(x)
}
R/partition.R:323
Complex.cl_partition untypeabletyped
unbound variable (line 337)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((z: any) -> empty)<>
timing: 0.002 s
source
Complex.cl_partition <-
function(z)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
R/partition.R:334
Math.cl_partition untypeabletyped
unbound variable (line 345)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((x: any, ...: any) -> empty)<>
timing: 0.003 s
source
Math.cl_partition <-
function(x, ...)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
R/partition.R:342
Ops.cl_partition untypeabletyped
unbound variable (line 353)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
gradual mode: typed
((e1: any, e2: any) -> any)<>
timing: 0.052 s
source
Ops.cl_partition <-
function(e1, e2)
{
if(nargs() == 1L)
stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
## Only comparisons are supprorted.
if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
"==", "!=")))
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
ci1 <- cl_class_ids(e1)
ci2 <- cl_class_ids(e2)
if(length(ci1) != length(ci2))
stop("Partitions must have the same number of objects.")
z <- table(ci1, ci2) > 0
switch(.Generic,
"<=" = all(rowSums(z) == 1),
"<" = all(rowSums(z) == 1) && any(colSums(z) > 1),
">=" = all(colSums(z) == 1),
">" = all(colSums(z) == 1) && any(rowSums(z) > 1),
"==" = all(rowSums(z) == 1) && all(colSums(z) == 1),
"!=" = any(rowSums(z) > 1) || any(colSums(z) > 1))
}
R/partition.R:350
Summary.cl_partition skipped
error detail
Failure("Unsupported positional argument after a named one.")timing: 0.003 s
source
Summary.cl_partition <-
function(..., na.rm = FALSE)
{
ok <- switch(.Generic, max = , min = , range = TRUE, FALSE)
if(!ok)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
args <- list(...)
switch(.Generic,
"min" = cl_meet(cl_ensemble(list = args)),
"max" = cl_join(cl_ensemble(list = args)),
"range" = {
cl_ensemble(min = cl_meet(cl_ensemble(list = args)),
max = cl_join(cl_ensemble(list = args)))
})
}
R/partition.R:382
is.cl_hard_partition.default typed any: x accepts outside
((x: any) -> ff<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.default() | ff<> with { } |
source
is.cl_hard_partition.default <- .false
R/partition.R:463
is.cl_hard_partition.kmeans typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.kmeans() | tt<> with { } |
source
is.cl_hard_partition.kmeans <- .true
R/partition.R:466
is.cl_hard_partition.partition typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.partition() | tt<> with { } |
source
is.cl_hard_partition.partition <- .true
R/partition.R:478
is.cl_hard_partition.Weka_clusterer typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.Weka_clusterer() | tt<> with { } |
source
is.cl_hard_partition.Weka_clusterer <- .true
R/partition.R:482
is.cl_hard_partition.ccfkms typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.ccfkms() | tt<> with { } |
source
is.cl_hard_partition.ccfkms <- .true
R/partition.R:485
is.cl_hard_partition.rock typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.rock() | tt<> with { } |
source
is.cl_hard_partition.rock <- .true
R/partition.R:487
is.cl_hard_partition.cclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.cclust() | tt<> with { } |
source
is.cl_hard_partition.cclust <- .true
R/partition.R:490
is.cl_hard_partition.fanny untypeabletyped
unbound variable (line 475)
unbound: cl_membership — one of the package’s own names, itself untyped
error detail
name: cl_membership
gradual mode: typed
((x: any) -> any)<>
timing: 0.005 s
source
is.cl_hard_partition.fanny <-
function(x)
{
all(rowSums(cl_membership(x) == 1, na.rm = TRUE) > 0)
}
R/partition.R:472
is.cl_hard_partition.fclust untypeabletyped
unbound variable (line 493)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.fclust <- is.cl_hard_partition.fanny
R/partition.R:493
is.cl_hard_partition.cshell untypeabletyped
unbound variable (line 495)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.cshell <- is.cl_hard_partition.fanny
R/partition.R:495
is.cl_hard_partition.bclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.bclust() | tt<> with { } |
source
is.cl_hard_partition.bclust <- .true
R/partition.R:497
is.cl_hard_partition.kcca typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.kcca() | tt<> with { } |
source
is.cl_hard_partition.kcca <- .true
R/partition.R:501
is.cl_hard_partition.flexmix untypeabletyped
unbound variable (line 504)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.flexmix <- is.cl_hard_partition.fanny
R/partition.R:504
is.cl_hard_partition.specc typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.004 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.specc() | tt<> with { } |
source
is.cl_hard_partition.specc <- .true
R/partition.R:508
is.cl_hard_partition.Mclust untypeabletyped
unbound variable (line 511)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.Mclust <- is.cl_hard_partition.fanny
R/partition.R:511
is.cl_hard_partition.cl_hard_partition typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.cl_hard_partition() | tt<> with { } |
source
is.cl_hard_partition.cl_hard_partition <- .true
R/partition.R:514
is.cl_hard_partition.kmedoids typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hard_partition.kmedoids() | tt<> with { } |
source
is.cl_hard_partition.kmedoids <- .true
R/partition.R:538
is.cl_hard_partition.pclust untypeabletyped
unbound variable (line 540)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.pclust <- is.cl_hard_partition.fanny
R/partition.R:540
is.cl_hard_partition.movMF untypeabletyped
unbound variable (line 543)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.movMF <- is.cl_hard_partition.fanny
R/partition.R:543
.cl_hard_partition_classes typed
CHR<>
timing: 0.019 s
source
.cl_hard_partition_classes <- c("cl_hard_partition", "cl_partition")
R/partition.R:547
cl_partition_by_class_ids untypeabletyped
unbound variable (line 405)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: <...>, labels: (vec | null)?) -> any)<>
timing: 0.025 s
source
cl_partition_by_class_ids <-
function(x, labels = NULL)
{
if(!is.atomic(x))
stop("Class ids must be atomic.")
if(is.null(names(x)))
names(x) <- labels
## <FIXME>
## Perhaps give the raw class ids more structure?
## E.g, class "cl_class_ids"?
## Problem is that we used to say about extensibility that all there
## is to do for a hard partitioner is to add a cl_class_ids() method
## and two predicates, but *not* to have the former give a suitably
## classed object. On the other hand, the recipe would need to be
## extended for soft partitioners, for which it would be necessary
## to provide a cl_membership() method which really returns an
## object of class cl_membership. Note that we can do this using
## as.cl_membership(m), where m is the raw membership matrix. So
## maybe we should ask for using as.cl_class_ids() to coerce raw
## class ids ...
.make_container(as.cl_class_ids(x),
c("cl_partition_by_class_ids",
.cl_hard_partition_classes),
list(n_of_objects = length(x),
n_of_classes = length(unique(x))))
## </FIXME>
}
R/partition.R:402
is.cl_hard_partition untypeabletyped
unbound variable (line 460)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hard_partition <-
function(x)
UseMethod("is.cl_hard_partition")
R/partition.R:458
is.cl_hard_partition.cl_partition untypeabletyped
unbound variable (line 535)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: { .Data: any with { is_cl_hard_partition: any, any }, any }) -> any)<>
timing: 0.047 s
source
is.cl_hard_partition.cl_partition <-
function(x)
{
## If the object has a cl_membership representation ...
y <- .get_representation(x)
if(inherits(y, "cl_membership"))
attr(y, "is_cl_hard_partition")
## Other representations, e.g. for "definitely" hard partitions via
## vectors of class ids or class labels, or a list of classes, may
## be added in future versions.
## In any case, this must be kept in sync with what is handled by
## as.cl_partition() [which currently runs as.cl_membership() in
## case is.cl_partition() gives false].
else
is.cl_hard_partition(y)
}
R/partition.R:521
as.cl_hard_partition untypeable
unbound variable (line 552)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
timing: 0.039 s
source
as.cl_hard_partition <-
function(x)
{
if(is.cl_hard_partition(x)) {
if(!inherits(x, "cl_partition"))
.make_container(x, .cl_hard_partition_classes)
else
x
}
else if(is.cl_partition(x)) {
## A soft cl_partition ...
ids <- cl_class_ids(x)
cl_partition_by_class_ids(ids, names(ids))
}
else if(is.matrix(x)) {
## A matrix of raw memberships, hopefully ...
cl_partition_by_class_ids(max.col(x), rownames(x))
}
else if(is.atomic(x)) {
## A vector of raw class ids, hopefully ...
cl_partition_by_class_ids(x, names(x))
}
else
stop("Cannot coerce to 'cl_hard_partition'.")
}
R/partition.R:549
is.cl_soft_partition untypeable
unbound variable (line 581)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
timing: 0.010 s
source
is.cl_soft_partition <-
function(x)
is.cl_partition(x) && ! is.cl_hard_partition(x)
R/partition.R:579
.maybe_is_proper_soft_partition untypeabletyped
unbound variable (line 591)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
.maybe_is_proper_soft_partition <-
function(x)
UseMethod(".maybe_is_proper_soft_partition")
R/partition.R:589
.maybe_is_proper_soft_partition.default typed any: x accepts outside
((x: any) -> ff<>)<>
timing: 0.006 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.default() | ff<> with { } |
source
.maybe_is_proper_soft_partition.default <- .false
R/partition.R:592
.maybe_is_proper_soft_partition.fanny typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.fanny() | tt<> with { } |
source
.maybe_is_proper_soft_partition.fanny <- .true
R/partition.R:593
.maybe_is_proper_soft_partition.fclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.fclust() | tt<> with { } |
source
.maybe_is_proper_soft_partition.fclust <- .true
R/partition.R:594
.maybe_is_proper_soft_partition.cshell typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.cshell() | tt<> with { } |
source
.maybe_is_proper_soft_partition.cshell <- .true
R/partition.R:595
.maybe_is_proper_soft_partition.flexmix typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.flexmix() | tt<> with { } |
source
.maybe_is_proper_soft_partition.flexmix <- .true
R/partition.R:596
.maybe_is_proper_soft_partition.Mclust typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | .maybe_is_proper_soft_partition.Mclust() | tt<> with { } |
source
.maybe_is_proper_soft_partition.Mclust <- .true
R/partition.R:597
.maybe_is_proper_soft_partition.cl_partition untypeabletyped
unbound variable (line 611)
unbound: .maybe_is_proper_soft_partition — one of the package’s own names, itself untyped
error detail
name: .maybe_is_proper_soft_partition
gradual mode: typed
((x: { .Data: any with { is_cl_hard_partition: dbl, any }, any }) -> any)<>
timing: 0.148 s
source
.maybe_is_proper_soft_partition.cl_partition <-
function(x)
{
y <- .get_representation(x)
if(inherits(y, "cl_membership"))
!attr(y, "is_cl_hard_partition")
else
.maybe_is_proper_soft_partition(y)
}
R/partition.R:604
.maybe_is_proper_soft_partition.pclust typed accepts outside
(((x: { m: vec, any }) -> LGL<>)&((x: { m: vec1, any }) -> LGL1<>))<>
timing: 0.076 s
fuzzing: 8 inside (3 ok, 5 error type) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | wrap | .maybe_is_proper_soft_partition.pclust(list(list("m" = NA_character_, function(...) new.env(), new.env()))) | (LGL & ~vec1)<> with { } |
Other calls inside the domain
| call | verdict | error |
|---|
| .maybe_is_proper_soft_partition.pclust("x" = list("m" = NA_complex_, as.name("x"))) | error_type | base::>: invalid comparison with complex values |
| .maybe_is_proper_soft_partition.pclust("x" = list("m" = c(complex(real = 0, imaginary = 0), NA_complex_, complex(real = 0, imaginary = 0), complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2)))) | error_type | base::>: invalid comparison with complex values |
| .maybe_is_proper_soft_partition.pclust(list("m" = complex(real = 1, imaginary = -2), function(...) NULL, local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))) | error_type | base::>: invalid comparison with complex values |
| .maybe_is_proper_soft_partition.pclust("x" = list("m" = complex(real = 1, imaginary = -2))) | error_type | base::>: invalid comparison with complex values |
| .maybe_is_proper_soft_partition.pclust("x" = list("m" = complex(real = 0, imaginary = 0), quote(f(x)))) | error_type | base::>: invalid comparison with complex values |
source
.maybe_is_proper_soft_partition.pclust <-
function(x)
x$m > 1
R/partition.R:613
R/objects.R
n_of_objects untypeabletyped
unbound variable (line 7)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
n_of_objects <-
function(x)
UseMethod("n_of_objects")
R/objects.R:5
n_of_objects.default untypeabletyped
unbound variable (line 13)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.002 s
source
n_of_objects.default <-
function(x)
length(cl_class_ids(x))
R/objects.R:11
n_of_objects.kmeans untypeabletyped
unbound variable (line 22)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.kmeans <- n_of_objects.default
R/objects.R:22
n_of_objects.partition untypeabletyped
unbound variable (line 26)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.partition <- n_of_objects.default
R/objects.R:26
n_of_objects.cclust untypeabletyped
unbound variable (line 29)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.cclust <- n_of_objects.default
R/objects.R:29
n_of_objects.fclust typed accepts outside
((x: { membership: any, any }) -> INT1<> | null)<>
timing: 0.025 s
fuzzing: 8 inside (8 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | kind:null | n_of_objects.fclust(NULL) | null |
source
n_of_objects.fclust <-
function(x)
nrow(x$membership)
R/objects.R:32
n_of_objects.cshell typed accepts outside
((x: { membership: any, any }) -> INT1<> | null)<>
timing: 0.008 s
fuzzing: 8 inside (8 ok) · 8 outside (6 rejected, 2 accepted)
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:lang | n_of_objects.cshell("x" = quote(f(x))) | null |
| x | unwrap | n_of_objects.cshell("x" = NULL) | null |
source
n_of_objects.cshell <- n_of_objects.fclust
R/objects.R:36
n_of_objects.bclust untypeabletyped
unbound variable (line 38)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.bclust <- n_of_objects.default
R/objects.R:38
n_of_objects.Mclust untypeabletyped
unbound variable (line 41)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.Mclust <- n_of_objects.default
R/objects.R:41
n_of_objects.hclust typed accepts outside
((x: { order: any, any }) -> INT1<>)<>
timing: 0.025 s
fuzzing: 8 inside (8 ok) · 4 outside (2 rejected, 2 accepted)
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:env | n_of_objects.hclust(new.env()) | 0L<> with { } |
| x | kind:null | n_of_objects.hclust("x" = NULL) | 0L<> with { } |
source
n_of_objects.hclust <-
function(x)
length(x$order)
R/objects.R:46
n_of_objects.twins typed accepts outside
((x: { order: any, any }) -> INT1<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 6 outside (4 rejected, 2 accepted)
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:env | n_of_objects.twins("x" = new.env()) | 0L<> with { } |
| x | kind:lang | n_of_objects.twins("x" = quote(f(x))) | 0L<> with { } |
source
n_of_objects.twins <- n_of_objects.hclust
R/objects.R:52
n_of_objects.mona typed accepts outside
((x: { order: any, any }) -> INT1<>)<>
timing: 0.008 s
fuzzing: 8 inside (8 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | kind:lang | n_of_objects.mona("x" = quote(f(x))) | 0L<> with { } |
source
n_of_objects.mona <- n_of_objects.hclust
R/objects.R:54
n_of_objects.phylo typed accepts outside
((x: { tip.label: any, any }) -> INT1<>)<>
timing: 0.025 s
fuzzing: 8 inside (8 ok) · 8 outside (6 rejected, 2 accepted)
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:env | n_of_objects.phylo("x" = new.env()) | 0L<> with { } |
| x | unwrap | n_of_objects.phylo(list()) | 0L<> with { } |
source
n_of_objects.phylo <-
function(x)
length(x$tip.label)
R/objects.R:57
n_of_objects.dist typed accepts outside
∀'a. ((x: any with { Size: 'a, any }) -> 'a)<>
timing: 0.022 s
fuzzing: 20 inside (20 ok) · 8 outside (4 rejected, 4 accepted)
type drawn from: ((x: any with { Size: 'I12420, any }) -> 'I12420)<>
Accepted outside the domain x: 4
| parameter | change | call | returned |
|---|
| x | attr:drop:Size | n_of_objects.dist(new.env()) | null |
| x | attr:drop:Size | n_of_objects.dist("x" = list(as.name("x"), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))) | null |
| x | attr:drop:Size | n_of_objects.dist("x" = quote(f(x))) | null |
| x | kind:chr | n_of_objects.dist("x" = "fuzz") | null |
source
n_of_objects.dist <-
function(x)
attr(x, "Size")
R/objects.R:64
n_of_objects.cl_ensemble typed accepts outside
∀'a. ((x: any with { n_of_objects: 'a, any }) -> 'a)<>
timing: 0.023 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { n_of_objects: 'I12427, any }) -> 'I12427)<>
Accepted outside the domain x: 7
| parameter | change | call | returned |
|---|
| x | kind:dbl | n_of_objects.cl_ensemble(1.5) | null |
| x | kind:list | n_of_objects.cl_ensemble("x" = list()) | null |
| x | kind:null | n_of_objects.cl_ensemble(NULL) | null |
| x | kind:null | n_of_objects.cl_ensemble("x" = NULL) | null |
| x | kind:sym | n_of_objects.cl_ensemble(as.name("x")) | null |
| x | wrap | n_of_objects.cl_ensemble("x" = list(structure(quote(f(x)), "n_of_objects" = -2147483647))) | null |
and 1 more
source
n_of_objects.cl_ensemble <-
function(x)
attr(x, "n_of_objects")
R/objects.R:69
n_of_objects.cl_membership typed any: x fuzz ok
(x: any) -> INT1<> | null
timing: 0.009 s
fuzzing: 7 inside (7 ok) · 8 outside (8 rejected)
source
n_of_objects.cl_membership <- nrow
R/objects.R:73
n_of_objects.pclust untypeabletyped
unbound variable (line 75)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.pclust <- n_of_objects.default
R/objects.R:75
n_of_objects.cl_ultrametric typed accepts outside
∀'a. ((x: any with { Size: 'a, any }) -> 'a)<>
timing: 0.007 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { Size: 'I12431, any }) -> 'I12431)<>
Accepted outside the domain x: 7
| parameter | change | call | returned |
|---|
| x | attr:drop:Size | n_of_objects.cl_ultrametric("x" = as.raw(c(0, 255))) | null |
| x | attr:drop:Size | n_of_objects.cl_ultrametric("x" = quote(f(x))) | null |
| x | kind:chr | n_of_objects.cl_ultrametric("fuzz") | null |
| x | kind:chr | n_of_objects.cl_ultrametric("x" = "fuzz") | null |
| x | kind:null | n_of_objects.cl_ultrametric(NULL) | null |
| x | kind:sym | n_of_objects.cl_ultrametric(as.name("x")) | null |
and 1 more
source
n_of_objects.cl_ultrametric <- n_of_objects.dist
R/objects.R:77
n_of_objects.cl_partition untypeabletyped
unbound variable (line 81)
unbound: .get_property_from_object_or_representation — one of the package’s own names, itself untyped
error detail
name: .get_property_from_object_or_representation
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
n_of_objects.cl_partition <-
function(x)
.get_property_from_object_or_representation(x, "n_of_objects")
R/objects.R:79
n_of_objects.cl_hierarchy untypeabletyped
unbound variable (line 85)
unbound: .get_property_from_object_or_representation — one of the package’s own names, itself untyped
error detail
name: .get_property_from_object_or_representation
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
n_of_objects.cl_hierarchy <-
function(x)
.get_property_from_object_or_representation(x, "n_of_objects")
R/objects.R:83
cl_object_names untypeabletyped
unbound variable (line 96)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_object_names <-
function(x)
UseMethod("cl_object_names")
R/objects.R:94
cl_object_names.default untypeabletyped
unbound variable (line 100)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> CHR<> | null)<>
timing: 0.002 s
source
cl_object_names.default <- function(x) names(cl_class_ids(x))
R/objects.R:100
cl_object_names.hclust typed accepts outside
∀'a. ((x: { labels: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { labels: 'I12455, any }) -> 'I12455)<>
Accepted outside the domain x: 2
| parameter | change | call | returned |
|---|
| x | kind:env | cl_object_names.hclust(new.env()) | null |
| x | kind:null | cl_object_names.hclust(NULL) | null |
source
cl_object_names.hclust <- function(x) x$labels
R/objects.R:122
cl_object_names.twins typed accepts outside
((x: { order.lab: null, any }) -> null)<>
timing: 0.071 s
fuzzing: 7 inside (7 ok) · 8 outside (4 rejected, 4 accepted)
Accepted outside the domain x: 4
| parameter | change | call | returned |
|---|
| x | kind:env | cl_object_names.twins("x" = new.env()) | null |
| x | kind:null | cl_object_names.twins(NULL) | null |
| x | unwrap | cl_object_names.twins("x" = NULL) | null |
| x | wrap | cl_object_names.twins("x" = list(list("order.lab" = NULL, NULL, quote(f(x))))) | null |
source
cl_object_names.twins <-
function(x)
{
if(!is.null(x$order.lab)) {
out <- character(length = n_of_objects(x))
out[x$order] <- x$order.lab
out
}
else
NULL
}
R/objects.R:129
cl_object_names.mona typed accepts outside
((x: { order.lab: null, any }) -> null)<>
timing: 0.005 s
fuzzing: 5 inside (5 ok) · 8 outside (4 rejected, 4 accepted)
Accepted outside the domain x: 4
| parameter | change | call | returned |
|---|
| x | wrap | cl_object_names.mona(list(list("order.lab" = NULL))) | null |
| x | wrap | cl_object_names.mona("x" = list(list("order.lab" = NULL))) | null |
| x | wrap | cl_object_names.mona("x" = list(list("order.lab" = NULL, c(FALSE, FALSE)))) | null |
| x | wrap | cl_object_names.mona(list(list("order.lab" = NULL, new.env(), NULL))) | null |
source
cl_object_names.mona <- cl_object_names.twins
R/objects.R:140
cl_object_names.phylo typed accepts outside
∀'a. ((x: { tip.label: 'a, any }) -> 'a)<>
timing: 0.021 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { tip.label: 'I12483, any }) -> 'I12483)<>
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | kind:env | cl_object_names.phylo("x" = new.env()) | null |
source
cl_object_names.phylo <-
function(x)
x$tip.label
R/objects.R:143
cl_object_names.dist typed accepts outside
∀'a. ((x: any with { Labels: 'a, any }) -> 'a)<>
timing: 0.022 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { Labels: 'I12490, any }) -> 'I12490)<>
Accepted outside the domain x: 7
| parameter | change | call | returned |
|---|
| x | attr:drop:Labels | cl_object_names.dist(new.env()) | null |
| x | attr:drop:Labels | cl_object_names.dist("x" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })) | null |
| x | kind:fun | cl_object_names.dist(function(...) NULL) | null |
| x | kind:lang | cl_object_names.dist("x" = quote(f(x))) | null |
| x | kind:null | cl_object_names.dist("x" = NULL) | null |
| x | wrap | cl_object_names.dist("x" = list(structure(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "Labels" = c(-2147483647, 0.5)))) | null |
and 1 more
source
cl_object_names.dist <-
function(x)
attr(x, "Labels")
R/objects.R:151
cl_object_names.cl_membership untypeabletyped
unbound variable (line 158)
unbound: rownames — a name the prelude does not declare
error detail
name: rownames
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_object_names.cl_membership <-
function(x)
rownames(x)
R/objects.R:156
cl_object_names.cl_ultrametric typed accepts outside
∀'a. ((x: any with { Labels: 'a, any }) -> 'a)<>
timing: 0.023 s
fuzzing: 20 inside (20 ok) · 8 outside (3 rejected, 5 accepted)
type drawn from: ((x: any with { Labels: 'I12501, any }) -> 'I12501)<>
Accepted outside the domain x: 5
| parameter | change | call | returned |
|---|
| x | attr:drop:Labels | cl_object_names.cl_ultrametric("x" = complex(0)) | null |
| x | attr:drop:Labels | cl_object_names.cl_ultrametric("x" = c(NA, FALSE)) | null |
| x | kind:chr | cl_object_names.cl_ultrametric("x" = "fuzz") | null |
| x | kind:list | cl_object_names.cl_ultrametric(list()) | null |
| x | wrap | cl_object_names.cl_ultrametric("x" = list(structure(as.raw(c(255)), "Labels" = ""))) | null |
source
cl_object_names.cl_ultrametric <-
function(x)
attr(x, "Labels")
R/objects.R:160
cl_object_names.cl_partition untypeabletyped
unbound variable (line 166)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
cl_object_names.cl_partition <-
function(x)
cl_object_names(.get_representation(x))
R/objects.R:164
cl_object_names.cl_hierarchy untypeabletyped
unbound variable (line 170)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.010 s
source
cl_object_names.cl_hierarchy <-
function(x)
cl_object_names(.get_representation(x))
R/objects.R:168
cl_object_names.cl_ensemble untypeabletyped
unbound variable (line 175)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: list) | (x: vec) -> any)<>
timing: 0.007 s
source
cl_object_names.cl_ensemble <-
function(x)
{
nms <- lapply(x, cl_object_names)
ind <- which(lengths(nms) > 0L)
if(any(ind)) nms[[ind[1L]]] else NULL
}
R/objects.R:172
cl_object_labels untypeable
unbound variable (line 185)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
timing: 0.008 s
source
cl_object_labels <-
function(x)
{
if(is.null(out <- cl_object_names(x)))
out <- as.character(seq_len(n_of_objects(x)))
out
}
R/objects.R:182
cl_object_dissimilarities untypeabletyped
unbound variable (line 200)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.008 s
source
cl_object_dissimilarities <-
function(x)
{
## Keep this in sync with .has_object_dissimilarities().
if(is.cl_dendrogram(x))
cl_ultrametric(x)
else if(inherits(x, "dist"))
x
else
stop("Cannot extract object dissimilarities")
}
R/objects.R:196
.has_object_dissimilarities untypeabletyped
unbound variable (line 212)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: any) -> ff<> | tt<>)<>
timing: 0.004 s
source
.has_object_dissimilarities <-
function(x)
{
## Keep this in sync with cl_object_dissimilarities().
is.cl_dendrogram(x) || inherits(x, "dist")
}
R/objects.R:208
R/hierarchy.R
is.cl_hierarchy untypeabletyped
unbound variable (line 16)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hierarchy <-
function(x)
UseMethod("is.cl_hierarchy")
R/hierarchy.R:14
is.cl_hierarchy.default typed any: x accepts outside
((x: any) -> ff<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hierarchy.default() | ff<> with { } |
source
is.cl_hierarchy.default <- .false
R/hierarchy.R:19
is.cl_hierarchy.hclust untypeabletyped
unbound variable (line 24)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { height: any, any }) -> any)<>
timing: 0.017 s
source
is.cl_hierarchy.hclust <-
function(x)
!is.unsorted(x$height)
R/hierarchy.R:22
is.cl_hierarchy.twins typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hierarchy.twins() | tt<> with { } |
source
is.cl_hierarchy.twins <- .true
R/hierarchy.R:28
is.cl_hierarchy.mona typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hierarchy.mona() | tt<> with { } |
source
is.cl_hierarchy.mona <- .true
R/hierarchy.R:30
is.cl_hierarchy.phylo untypeabletyped
unbound variable (line 35)
unbound: ape::is.ultrametric — a name the prelude does not declare
error detail
name: ape::is.ultrametric
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hierarchy.phylo <-
function(x)
ape::is.ultrametric(x)
R/hierarchy.R:33
is.cl_hierarchy.cl_hierarchy typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 5 inside (5 ok) · 6 outside (5 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_hierarchy.cl_hierarchy() | tt<> with { } |
source
is.cl_hierarchy.cl_hierarchy <- .true
R/hierarchy.R:44
.cl_hierarchy_classes typed
"cl_hierarchy"<>
timing: 0.002 s
source
.cl_hierarchy_classes <- "cl_hierarchy"
R/hierarchy.R:51
as.cl_hierarchy untypeabletyped
unbound variable (line 56)
unbound: is.cl_hierarchy — one of the package’s own names, itself untyped
error detail
name: is.cl_hierarchy
gradual mode: typed
((x: any) -> any)<>
timing: 0.029 s
source
as.cl_hierarchy <-
function(x)
{
if(is.cl_hierarchy(x)) {
if(!inherits(x, "cl_hierarchy"))
.make_container(x, .cl_hierarchy_classes)
else
x
}
else
.make_container(as.cl_ultrametric(x),
.cl_hierarchy_classes)
}
R/hierarchy.R:53
print.cl_hierarchy untypeabletyped
unbound variable (line 71)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.005 s
source
print.cl_hierarchy <-
function(x, ...)
.print_container(x, "cl_hierarchy", ...)
R/hierarchy.R:69
Complex.cl_hierarchy untypeabletyped
unbound variable (line 79)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((z: any) -> empty)<>
timing: 0.002 s
source
Complex.cl_hierarchy <-
function(z)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
R/hierarchy.R:76
Math.cl_hierarchy untypeabletyped
unbound variable (line 88)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((x: any, ...: any) -> empty)<>
timing: 0.003 s
source
Math.cl_hierarchy <-
function(x, ...)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
R/hierarchy.R:85
Ops.cl_hierarchy untypeabletyped
unbound variable (line 96)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
gradual mode: typed
((e1: any, e2: any) -> any)<>
timing: 0.059 s
source
Ops.cl_hierarchy <-
function(e1, e2)
{
if(nargs() == 1L)
stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
## Only comparisons are supprorted.
if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
"==", "!=")))
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
if(n_of_objects(e1) != n_of_objects(e2))
stop("Hierarchies must have the same number of objects.")
c1 <- cl_classes(e1)
c2 <- cl_classes(e2)
switch(.Generic,
"<=" = all(is.finite(match(c1, c2))),
"<" = all(is.finite(match(c1, c2))) && any(is.na(match(c2, c1))),
">=" = all(is.finite(match(c2, c1))),
">" = all(is.finite(match(c2, c1))) && any(is.na(match(c1, c2))),
"==" = all(is.finite(match(c1, c2))) && all(is.finite(match(c2, c1))),
"!=" = any(is.na(match(c1, c2))) || any(is.na(match(c2, c1))))
}
R/hierarchy.R:93
Summary.cl_hierarchy skipped
error detail
Failure("Unsupported positional argument after a named one.")timing: 0.003 s
source
Summary.cl_hierarchy <-
function(..., na.rm = FALSE)
{
ok <- switch(.Generic, max = , min = , range = TRUE, FALSE)
if(!ok)
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
args <- list(...)
switch(.Generic,
"min" = cl_meet(cl_ensemble(list = args)),
"max" = cl_join(cl_ensemble(list = args)),
"range" = {
cl_ensemble(min = cl_meet(cl_ensemble(list = args)),
max = cl_join(cl_ensemble(list = args)))
})
}
R/hierarchy.R:129
as.hclust.cl_hierarchy untypeabletyped
unbound variable (line 151)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((x: { .Data: any, any }, ...: any) -> any)<>
timing: 0.016 s
source
as.hclust.cl_hierarchy <-
function(x, ...)
as.hclust(.get_representation(x), ...)
R/hierarchy.R:149
is.cl_dendrogram untypeabletyped
unbound variable (line 165)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_dendrogram <-
function(x)
UseMethod("is.cl_dendrogram")
R/hierarchy.R:163
is.cl_dendrogram.default typed any: x accepts outside
((x: any) -> ff<>)<>
timing: 0.006 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_dendrogram.default() | ff<> with { } |
source
is.cl_dendrogram.default <- .false
R/hierarchy.R:167
is.cl_dendrogram.hclust untypeabletyped
unbound variable (line 171)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { height: any, any }) -> any)<>
timing: 0.017 s
source
is.cl_dendrogram.hclust <-
function(x)
!is.unsorted(x$height)
R/hierarchy.R:169
is.cl_dendrogram.twins typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_dendrogram.twins() | tt<> with { } |
source
is.cl_dendrogram.twins <- .true
R/hierarchy.R:174
is.cl_dendrogram.mona typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_dendrogram.mona() | tt<> with { } |
source
is.cl_dendrogram.mona <- .true
R/hierarchy.R:176
is.cl_dendrogram.phylo untypeabletyped
unbound variable (line 180)
unbound: ape::is.ultrametric — a name the prelude does not declare
error detail
name: ape::is.ultrametric
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
is.cl_dendrogram.phylo <-
function(x)
ape::is.ultrametric(x)
R/hierarchy.R:178
is.cl_dendrogram.cl_dendrogram typed any: x accepts outside
((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)
Accepted outside the domain x: 1
| parameter | change | call | returned |
|---|
| x | drop | is.cl_dendrogram.cl_dendrogram() | tt<> with { } |
source
is.cl_dendrogram.cl_dendrogram <- .true
R/hierarchy.R:184
.cl_dendrogram_classes typed
CHR<>
timing: 0.022 s
source
.cl_dendrogram_classes <- c("cl_dendrogram", "cl_hierarchy")
R/hierarchy.R:188
as.cl_dendrogram untypeabletyped
unbound variable (line 193)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: any) -> any)<>
timing: 0.033 s
source
as.cl_dendrogram <-
function(x)
{
if(is.cl_dendrogram(x)) {
if(!inherits(x, "cl_dendrogram"))
.make_container(x, .cl_dendrogram_classes)
else
x
}
else
.make_container(as.cl_ultrametric(x),
.cl_dendrogram_classes)
}
R/hierarchy.R:190
print.cl_dendrogram untypeabletyped
unbound variable (line 208)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.006 s
source
print.cl_dendrogram <-
function(x, ...)
.print_container(x, "cl_dendrogram", ...)
R/hierarchy.R:206
plot.cl_dendrogram untypeabletyped
unbound variable (line 214)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: typed
((x: { .Data: { .Data: any, any } with { Labels: null, any }, any }, ...: any) -> any)<>
timing: 0.015 s
source
plot.cl_dendrogram <-
function(x, ...)
plot(cl_ultrametric(.get_representation(x)), ...)
R/hierarchy.R:212
Ops.cl_dendrogram untypeable
unbound variable (line 221)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
timing: 0.049 s
source
Ops.cl_dendrogram <-
function(e1, e2)
{
if(nargs() == 1L)
stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
## Only comparisons are supprorted.
if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
"==", "!=")))
stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
.Generic, .Class),
domain = NA)
u1 <- cl_ultrametric(e1)
u2 <- cl_ultrametric(e2)
if(length(u1) != length(u2))
stop("Dendrograms must have the same number of objects.")
switch(.Generic,
"<=" = all(u1 <= u2),
"<" = all(u1 <= u2) && any(u1 < u2),
">=" = all(u1 >= u2),
">" = all(u1 >= u2) && any(u1 > u2),
"==" = all(u1 == u2),
"!=" = any(u1 != u2))
}
R/hierarchy.R:218
cut.cl_dendrogram untypeabletyped
unbound variable (line 293)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.004 s
source
cut.cl_dendrogram <-
function(x, ...)
cutree(as.hclust(x), ...)
R/hierarchy.R:291
cophenetic.mona skipped
error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
cophenetic.mona <-
function(x)
{
no <- length(x$order)
ns <- max(x$step) + 1
m <- matrix(NA, no, no)
FOO <- function(ind, step, s) {
if(length(ind) <= 1) return()
grp <- c(0, cumsum(step == s))
ind <- split(ind, grp)
len <- length(ind)
for(a in seq_len(len)) {
for(b in seq_len(a - 1L)) {
## Need both as we currently cannot assume that the
## indices are sorted. Alternatively, work with the
## sequence from one to the number of objects, and
## reorder at the end ...
m[ind[[a]], ind[[b]]] <<- s
m[ind[[b]], ind[[a]]] <<- s
}
}
ind <- ind[lengths(ind) > 1L]
pos <- which(step == s)
step <- split(step[-pos], grp[-1][-pos])
if(is.null(step)) return()
for(a in seq_along(ind))
FOO(ind[[a]], step[[a]], s + 1)
}
FOO(x$order, x$step, 1)
m[is.na(m)] <- ns
m <- ns - m
rownames(m) <- rownames(x$data)
as.dist(m)
}
R/hierarchy.R:300
as.hclust.mona untypeabletyped
unbound variable (line 342)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.004 s
source
as.hclust.mona <-
function(x, ...)
hclust(cophenetic(x), "single")
R/hierarchy.R:340
R/addtree.R
.cl_addtree_from_veclh untypeabletyped
unbound variable (line 374)
unbound: cl_proximity — one of the package’s own names, itself untyped
error detail
name: cl_proximity
gradual mode: typed
((x: any, size: any?, labels: any?) -> any)<>
timing: 0.038 s
source
.cl_addtree_from_veclh <-
function(x, size = NULL, labels = NULL)
{
cl_proximity(x, "Additive tree distances",
labels = labels, size = size,
class = c("cl_addtree", "cl_dissimilarity",
"cl_proximity", "dist"))
}
R/addtree.R:371
.non_additivity untypeable
unbound variable (line 290)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
timing: 0.052 s
source
.non_additivity <-
function(x, max = FALSE)
{
if(!is.matrix(x))
x <- .symmetric_matrix_from_veclh(x)
.C(C_deviation_from_additivity,
as.double(x),
as.integer(nrow(x)),
fn = double(1L),
as.logical(max))$fn
}
R/addtree.R:286
.cl_addtree_from_addtree_approximation untypeabletyped
unbound variable (line 387)
unbound: .non_additivity — one of the package’s own names, itself untyped
error detail
name: .non_additivity
gradual mode: typed
((x: any, size: any?, labels: any?) -> any)<>
timing: 0.020 s
source
.cl_addtree_from_addtree_approximation <-
function(x, size = NULL, labels = NULL)
{
## Turn x into an addtree after possibly rounding to non-additivity
## significance (note that this is not guaranteed to work ...).
mnum <- .non_additivity(x, max = TRUE)
x <- round(x, floor(abs(log10(mnum))))
.cl_addtree_from_veclh(x, size = size, labels = labels)
}
R/addtree.R:382
.make_penalty_function_addtree untypeabletyped
unbound variable (line 113)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: any) -> ((d: any) -> any)<>)<>
timing: 0.020 s
source
.make_penalty_function_addtree <-
function(n)
function(d) {
(.non_additivity(.symmetric_matrix_from_veclh(d, n))
+ sum(pmin(d, 0) ^ 2))
}
R/addtree.R:110
.make_penalty_gradient_addtree untypeabletyped
unbound variable (line 121)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: dbl1<~@"*", ...>) -> ((d: any) -> any)<>)<>
timing: 0.040 s
source
.make_penalty_gradient_addtree <-
function(n)
function(d) {
gr <- matrix(.C(C_deviation_from_additivity_gradient,
as.double(.symmetric_matrix_from_veclh(d, n)),
as.integer(n),
gr = double(n * n))$gr,
n, n)
gr[row(gr) > col(gr)] + 2 * sum(pmin(d, 0))
}
R/addtree.R:117
.ls_fit_addtree_by_SUMT untypeable
untypeable application of base::$ (line 50)
error detail
argument: @({ }<> | 'control, "gradient"<>)
failing call: base::$(list(), "gradient")timing: 0.192 s
source
.ls_fit_addtree_by_SUMT <-
function(x, weights = 1, control = list())
{
## Control parameters:
## gradient,
gradient <- control$gradient
if(is.null(gradient))
gradient <- TRUE
## nruns,
nruns <- control$nruns
## start,
start <- control$start
## Handle start values and number of runs.
if(!is.null(start)) {
if(!is.list(start)) {
## Be nice to users.
start <- list(start)
}
} else if(is.null(nruns)) {
## Use nruns only if start is not given.
nruns <- 1L
}
w <- weights / sum(weights)
n <- attr(x, "Size")
labels <- attr(x, "Labels")
## Handle missing values in x along the lines of de Soete (1984):
## set the corresponding weights to 0, and impute by the weighted
## mean.
ind <- which(is.na(x))
if(any(ind)) {
w[ind] <- 0
x[ind] <- weighted.mean(x, w, na.rm = TRUE)
}
L <- function(d) sum(w * (d - x) ^ 2)
P <- .make_penalty_function_addtree(n)
if(gradient) {
grad_L <- function(d) 2 * w * (d - x)
grad_P <- .make_penalty_gradient_addtree(n)
}
else {
grad_L <- grad_P <- NULL
}
if(is.null(start)) {
## Initialize by "random shaking". Use sd() for simplicity.
start <- replicate(nruns,
x + rnorm(length(x), sd = sd(x) / sqrt(3)),
simplify = FALSE)
}
## And now ...
d <- sumt(start, L, P, grad_L, grad_P,
method = control$method, eps = control$eps,
q = control$q, verbose = control$verbose,
control = as.list(control$control))$x
## Round to enforce additivity, and hope for the best ...
.cl_addtree_from_addtree_approximation(d, n, labels)
}
R/addtree.R:45
.ls_fit_addtree_by_iterative_projection untypeable
unbound variable (line 143)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.205 s
source
.ls_fit_addtree_by_iterative_projection <-
function(x, weights = 1, control = list())
{
if(any(diff(weights)))
warning("Non-identical weights currently not supported.")
labels <- attr(x, "Labels")
x <- as.matrix(x)
n <- nrow(x)
## Control parameters:
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 10000L
## nruns,
nruns <- control$nruns
## order,
order <- control$order
## tol,
tol <- control$tol
if(is.null(tol))
tol <- 1e-8
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle order and nruns.
if(!is.null(order)) {
if(!is.list(order))
order <- as.list(order)
if(!all(vapply(order,
function(o) all(sort(o) == seq_len(n)),
NA)))
stop("All given orders must be valid permutations.")
}
else {
if(is.null(nruns))
nruns <- 1L
order <- replicate(nruns, sample(n), simplify = FALSE)
}
ind <- lower.tri(x)
L <- function(d) sum(weights * (x - d)[ind] ^ 2)
d_opt <- NULL
v_opt <- Inf
for(run in seq_along(order)) {
if(verbose)
message(gettextf("Iterative projection run: %d", run))
d <- .C(C_ls_fit_addtree_by_iterative_projection,
as.double(x),
as.integer(n),
as.integer(order[[run]] - 1L),
as.integer(maxiter),
iter = integer(1L),
as.double(tol),
as.logical(verbose))[[1L]]
v <- L(d)
if(v < v_opt) {
v_opt <- v
d_opt <- d
}
}
d <- matrix(d_opt, n)
dimnames(d) <- list(labels, labels)
.cl_addtree_from_addtree_approximation(as.dist(d))
}
R/addtree.R:140
.ls_fit_addtree_by_iterative_reduction untypeable
unbound variable (line 216)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.207 s
source
.ls_fit_addtree_by_iterative_reduction <-
function(x, weights = 1, control = list())
{
if(any(diff(weights)))
warning("Non-identical weights currently not supported.")
labels <- attr(x, "Labels")
x <- as.matrix(x)
n <- nrow(x)
## Control parameters:
## maxiter,
maxiter <- control$maxiter
if(is.null(maxiter))
maxiter <- 10000L
## nruns,
nruns <- control$nruns
## order,
order <- control$order
## tol,
tol <- control$tol
if(is.null(tol))
tol <- 1e-8
## verbose.
verbose <- control$verbose
if(is.null(verbose))
verbose <- getOption("verbose")
## Handle order and nruns.
if(!is.null(order)) {
if(!is.list(order))
order <- as.list(order)
if(!all(vapply(order,
function(o) all(sort(o) == seq_len(n)),
NA)))
stop("All given orders must be valid permutations.")
}
else {
if(is.null(nruns))
nruns <- 1L
order <- replicate(nruns, sample(n), simplify = FALSE)
}
ind <- lower.tri(x)
L <- function(d) sum(weights * (x - d)[ind] ^ 2)
d_opt <- NULL
v_opt <- Inf
for(run in seq_along(order)) {
if(verbose)
message(gettextf("Iterative reduction run: %d", run))
d <- .C(C_ls_fit_addtree_by_iterative_reduction,
as.double(x),
as.integer(n),
as.integer(order[[run]] - 1L),
as.integer(maxiter),
iter = integer(1L),
as.double(tol),
as.logical(verbose))[[1L]]
v <- L(d)
if(v < v_opt) {
v_opt <- v
d_opt <- d
}
}
d <- matrix(d_opt, n)
dimnames(d) <- list(labels, labels)
.cl_addtree_from_addtree_approximation(as.dist(d))
}
R/addtree.R:213
as.cl_addtree untypeabletyped
unbound variable (line 343)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_addtree <-
function(x)
UseMethod("as.cl_addtree")
R/addtree.R:341
ls_fit_addtree untypeable
unbound variable (line 8)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
timing: 0.169 s
source
ls_fit_addtree <-
function(x, method = c("SUMT", "IP", "IR"), weights = 1,
control = list())
{
if(!inherits(x, "dist"))
x <- as.dist(x)
## Catch some special cases right away.
if(attr(x, "Size") <= 3L)
return(as.cl_addtree(x))
if(.non_additivity(x, max = TRUE) == 0)
return(as.cl_addtree(x))
## Handle argument 'weights'.
## This is somewhat tricky ...
if(is.matrix(weights)) {
weights <- as.dist(weights)
if(length(weights) != length(x))
stop("Argument 'weights' must be compatible with 'x'.")
}
else
weights <- rep_len(weights, length(x))
if(any(weights < 0))
stop("Argument 'weights' has negative elements.")
if(!any(weights > 0))
stop("Argument 'weights' has no positive elements.")
method <- match.arg(method)
switch(method,
SUMT = .ls_fit_addtree_by_SUMT(x, weights, control),
IP = {
.ls_fit_addtree_by_iterative_projection(x, weights,
control)
},
IR = {
.ls_fit_addtree_by_iterative_reduction(x, weights,
control)
})
}
R/addtree.R:3
.make_centroid_matrix untypeabletyped
unbound variable (line 334)
unbound: outer — a name the prelude does not declare
error detail
name: outer
gradual mode: typed
((g: any) -> any)<>
timing: 4.72 s
source
.make_centroid_matrix <-
function(g)
{
y <- outer(g, g, `+`)
diag(y) <- 0
y
}
R/addtree.R:331
ls_fit_centroid untypeabletyped
unbound variable (line 324)
unbound: as.cl_addtree — one of the package’s own names, itself untyped
error detail
name: as.cl_addtree
gradual mode: typed
((x: dbl with { Size: dbl<~@"-", ~@"*", ...>, any }) | (x: dbl with { Size: vec<@"-", ...>, any }) -> any)<>
timing: 0.501 s
source
ls_fit_centroid <-
function(x)
{
## Fit a centroid additive tree distance along the lines of Carroll
## & Pruzansky (1980). In fact, solving
##
## \sum_{i,j: i \ne j} (\delta_{ij} - (g_i + g_j)) ^ 2 => min_g
##
## gives \sum_{j: j \ne i} (g_i + g_j - \delta_{ij}) = 0, or (also
## in Barthemely & Guenoche)
##
## (n - 2) g_i + \sum_j g_j = \sum_{j: j \ne i} \delta_{ij}
##
## which after summing over all i and some manipulations eventually
## gives
##
## g_i = \frac{1}{n-2} (v_i - m),
##
## v_i = \sum_{j: j \ne i} \delta_{ij}
## s = \frac{1}{2(n-1)} \sum_{i,j: j \ne i} \delta_{ij}
n <- attr(x, "Size")
if(n <= 2L)
return(as.cl_addtree(0 * x))
x <- as.matrix(x)
g <- rowSums(x) / (n - 2) - sum(x) / (2 * (n - 1) * (n - 2))
as.cl_addtree(as.dist(.make_centroid_matrix(g)))
}
R/addtree.R:300
as.cl_addtree.default untypeabletyped
unbound variable (line 350)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.040 s
source
as.cl_addtree.default <-
function(x)
{
if(inherits(x, "cl_addtree"))
x
else if(is.atomic(x) || inherits(x, "cl_ultrametric"))
.cl_addtree_from_veclh(x)
else if(is.matrix(x)) {
## Should actually check whether the matrix is symmetric, >= 0
## and satisfies the 4-point conditions ...
.cl_addtree_from_veclh(as.dist(x))
}
else if(is.cl_dendrogram(x))
.cl_addtree_from_veclh(cl_ultrametric(x))
else
stop("Cannot coerce to 'cl_addtree'.")
}
R/addtree.R:345
as.cl_addtree.phylo untypeabletyped
unbound variable (line 365)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_addtree.phylo <-
function(x)
.cl_addtree_from_veclh(as.dist(cophenetic(x)))
R/addtree.R:363
.decompose_addtree untypeabletyped
unbound variable (line 409)
unbound: as.matrix — a name the prelude does not declare
error detail
name: as.matrix
gradual mode: typed
((x: any, const: null?) -> any)<>
timing: 0.066 s
source
.decompose_addtree <-
function(x, const = NULL)
{
## Decompose an addtree into an ultrametric and a centroid
## distance.
## If 'const' is not given, we take the root as half way between the
## diameter of the addtree, and choose a minimal constant to ensure
## non-negativity (but not positivity) of the ultrametric.
## As this is all slightly dubious and it is not quite clear how
## much positivity we want in the ultrametric of the decomposition,
## we keep this hidden. For plotting addtrees, the choice of the
## constant does not seem to matter.
x <- as.matrix(x)
n <- nrow(x)
## Determine diameter.
ind <- which.max(x) - 1
u <- ind %% n + 1
v <- ind %/% n + 1
if(!is.null(const))
g <- pmax(x[u, ], x[v, ]) - const
else {
g <- pmax(x[u, ], x[v, ]) - x[u, v] / 2
u <- x - .make_centroid_matrix(g)
k <- - min(u)
g <- g - k / 2
}
u <- x - .make_centroid_matrix(g)
names(g) <- rownames(x)
## Ensure a valid ultrametric.
d <- .ultrametrify(as.dist(u))
u <- .cl_ultrametric_from_veclh(d, nrow(x), rownames(x))
## Note that we return the centroid distances to the root, and not
## between the objects (as.dist(.make_centroid_matrix(g))) ...
list(Ultrametric = as.cl_ultrametric(u), Centroid = g)
}
R/addtree.R:394
plot.cl_addtree untypeable
unbound variable (line 445)
unbound: .decompose_addtree — one of the package’s own names, itself untyped
error detail
name: .decompose_addtree
timing: 0.055 s
source
plot.cl_addtree <-
function(x, ...)
{
## Construct a dendrogram-style representation of the addtree with
## the root half way between the diameter, and plot.
y <- .decompose_addtree(x, max(x))
u <- y$Ultrametric
g <- y$Centroid
## We halve the scale of the ultrametric, and add the maximal g from
## the centroid.
h <- hclust(as.dist(u / 2), "single")
h$height <- h$height + max(g)
d <- as.dendrogram(h)
## Now modify the heights of the leaves so that the objects giving
## the diameter of the addtree end up with height zero.
g <- max(g) - g
names(g) <- labels(g)
d <- dendrapply(d, function(n) {
if(!is.leaf(n)) return(n)
attr(n, "height") <- g[attr(n, "label")]
n
})
## And finally plot
plot(d, ...)
}
R/addtree.R:440
R/predict.R
cl_predict untypeabletyped
unbound variable (line 9)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.028 s
source
cl_predict <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
UseMethod("cl_predict")
R/predict.R:6
.as_cl_class_ids_or_membership untypeabletyped
unbound variable (line 307)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: <...>, type: (vec | null)?) -> any)<>
timing: 0.074 s
source
.as_cl_class_ids_or_membership <-
function(x, type = c("class_ids", "memberships"))
{
type <- match.arg(type)
if(type == "class_ids") {
if(is.matrix(x)) {
## Same as for cl_class_ids.cl_membership().
as.cl_class_ids(.structure(max.col(x), names = rownames(x)))
}
else
as.cl_class_ids(x)
}
else
as.cl_membership(x)
}
R/predict.R:299
cl_predict.default untypeabletyped
unbound variable (line 16)
unbound: predict — a name the prelude does not declare
error detail
name: predict
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.032 s
source
cl_predict.default <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
.as_cl_class_ids_or_membership(predict(object, newdata, ...), type)
R/predict.R:13
.cl_class_ids_or_membership untypeabletyped
unbound variable (line 294)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, type: (vec | null)?) -> any)<>
timing: 0.056 s
source
.cl_class_ids_or_membership <-
function(x, type = c("class_ids", "memberships"))
{
type <- match.arg(type)
if(type == "class_ids")
cl_class_ids(x)
else
cl_membership(x)
}
R/predict.R:288
cl_predict.kmeans untypeabletyped
unbound variable (line 24)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.073 s
source
cl_predict.kmeans <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
d <- .rxdist(newdata, object$centers)
.as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:19
cl_predict.fanny untypeabletyped
unbound variable (line 49)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.068 s
source
cl_predict.fanny <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
stop("Cannot make new predictions.")
}
R/predict.R:44
cl_predict.clara untypeabletyped
unbound variable (line 58)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.101 s
source
cl_predict.clara <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
## <FIXME>
## Add support eventually ...
if(identical(object$call$stand, TRUE))
warning("Standardization is currently not supported.")
## </FIXME>
method <- object$call$metric
if(is.null(method)) {
## Not given in the call, hence use default value.
method <- eval(formals(clara)$metric)[1L]
## (Or hard-wire the default value: "euclidean".)
}
d <- .rxdist(newdata, object$medoids, method)
.as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:53
cl_predict.pam untypeabletyped
unbound variable (line 79)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.105 s
source
cl_predict.pam <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
prototypes <- object$medoids
if(!is.matrix(prototypes))
stop("Cannot make new predictions.")
## <FIXME>
## Add support eventually ...
if(identical(object$call$stand, TRUE))
warning("Standardization is currently not supported.")
## </FIXME>
method <- object$call$metric
if(is.null(method)) {
## Not given in the call, hence use default value.
method <- eval(formals(pam)$metric)[1L]
## (Or hard-wire the default value: "euclidean".)
}
d <- .rxdist(newdata, object$medoids, method)
.as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:74
cl_predict.Weka_clusterer untypeabletyped
unbound variable (line 105)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.161 s
source
cl_predict.Weka_clusterer <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
.as_cl_class_ids_or_membership(predict(object, newdata = newdata,
type = type, ...),
type)
}
R/predict.R:100
cl_predict.ccfkms untypeabletyped
unbound variable (line 117)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.066 s
source
cl_predict.ccfkms <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
.as_cl_class_ids_or_membership(as.vector(predict(object,
newdata)$cl),
type)
}
R/predict.R:112
cl_predict.rock untypeabletyped
unbound variable (line 134)
unbound: predict — a name the prelude does not declare
error detail
name: predict
gradual mode: typed
((object: { x: null, any }, newdata: null?, type: any?, ...: any) -> any)<>
timing: 0.109 s
source
cl_predict.rock <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata)) newdata <- object$x
ids <- as.vector(predict(object, newdata, ...)$cl)
.as_cl_class_ids_or_membership(ids, type)
}
R/predict.R:129
cl_predict.cclust untypeabletyped
unbound variable (line 147)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.067 s
source
cl_predict.cclust <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
## Package cclust provides predict.cclust() which returns (again) an
## object of class "cclust", but does not give the labels of the
## original data in case no new data are given.
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
.as_cl_class_ids_or_membership(predict(object, newdata), type)
}
R/predict.R:139
cl_predict.fclust untypeabletyped
unbound variable (line 157)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.092 s
source
cl_predict.fclust <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
## Note that the 'fclust' objects returned by cmeans() do not always
## directly contain the information on the fuzzification parameter m
## and the distance (Euclidean/Manhattan) employed, so we have to
## engineer this from the matched call and the default arguments.
nms <- names(object$call)
## Note that we cannot directly use object$call$m, as this could
## give the 'method' argument if 'm' was not given.
m <- if("m" %in% nms)
object$call$m
else {
## Not given in the call, hence use default value.
formals(e1071::cmeans)$m
## (Or hard-wire the default value: 2.)
}
method <- if("dist" %in% nms)
object$call$dist
else {
## Not given in the call, hence use default value.
formals(e1071::cmeans)$dist
## (Or hard-wire the default value: "euclidean".)
}
d <- .rxdist(newdata, object$centers, method)
power <- c(m, if(method == "euclidean") 2 else 1)
M <- .memberships_from_cross_dissimilarities(d, power)
.as_cl_class_ids_or_membership(M, type)
}
R/predict.R:152
cl_predict.cshell untypeabletyped
unbound variable (line 193)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.094 s
source
cl_predict.cshell <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
## Not surprisingly, this is rather similar to what we do for fclust
## objects. Only dissimiliraties (and exponents) need to be
## computed differently ...
nms <- names(object$call)
m <- if("m" %in% nms)
object$call$m
else {
## Not given in the call, hence use default value.
formals(e1071::cshell)$m
## (Or hard-wire the default value: 2.)
}
method <- if("dist" %in% nms)
object$call$dist
else {
## Not given in the call, hence use default value.
formals(e1071::cshell)$dist
## (Or hard-wire the default value: "euclidean".)
}
d <- .rxdist(newdata, object$centers, method)
d <- sweep(d, 2, object$radius) ^ 2
M <- .memberships_from_cross_dissimilarities(d, m)
.as_cl_class_ids_or_membership(M, type)
}
R/predict.R:188
cl_predict.bclust untypeabletyped
unbound variable (line 225)
unbound: cl_predict.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_predict.kmeans
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.bclust <- cl_predict.kmeans
R/predict.R:225
cl_predict.kcca untypeabletyped
unbound variable (line 230)
unbound: cl_predict.default — one of the package’s own names, itself untyped
error detail
name: cl_predict.default
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.kcca <- cl_predict.default
R/predict.R:230
cl_predict.flexmix untypeabletyped
unbound variable (line 238)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.062 s
source
cl_predict.flexmix <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
.as_cl_class_ids_or_membership(modeltools::posterior(object,
newdata,
...),
type)
}
R/predict.R:233
cl_predict.Mclust untypeabletyped
unbound variable (line 251)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.076 s
source
cl_predict.Mclust <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
pred <- predict(object, newdata, ...)
type <- match.arg(type)
if(type == "class_ids")
as.cl_class_ids(pred$classification)
else
as.cl_membership(pred$z)
}
R/predict.R:246
cl_predict.movMF untypeabletyped
unbound variable (line 263)
unbound: cl_predict.Weka_clusterer — one of the package’s own names, itself untyped
error detail
name: cl_predict.Weka_clusterer
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.movMF <- cl_predict.Weka_clusterer
R/predict.R:263
cl_predict.pclust untypeabletyped
unbound variable (line 271)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.077 s
source
cl_predict.pclust <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
{
if(is.null(newdata))
return(.cl_class_ids_or_membership(object, type))
d <- object$family$D(newdata, object$prototypes)
power <- c(object$m, object$family$e)
M <- .memberships_from_cross_dissimilarities(d, power)
.as_cl_class_ids_or_membership(M, type)
}
R/predict.R:266
cl_predict.cl_partition skipped
error detail
Failure("Unsupported positional argument after a named one.")timing: 0.000 s
source
cl_predict.cl_partition <-
function(object, newdata = NULL,
type = c("class_ids", "memberships"), ...)
cl_predict(.get_representation(object), newdata = newdata, type, ...)
R/predict.R:280