criterion_methods

0th

Percentile

Registry for Criterion Methods

A registry to manage methods to calculate a criterion value given data and a permutation.

Keywords
misc
Usage
list_criterion_methods(kind)
show_criterion_methods(kind)
get_criterion_method(kind, name)
set_criterion_method(kind, name, fun, description = NULL, merit = NA, ...)
Arguments
kind
the data type the method works on. For example, "dist", "matrix" or "array".
name
a short name for the method used to refer to the method in the function criterion().
fun
a function containing the method's code.
description
a description of the method. For example, a long name.
merit
a boolean indicating if the criterion measure is a merit (TRUE) or a loss (FALSE) measure.
...
further information that is stored for the method in the registry.
Details

All methods below are convenience methods for the registry named registry_criterion.

list_criterion_method() lists all available methods for a given data type (kind). The result is a vector of character strings with the short names of the methods.

show_criterion_method() shows all available methods for a given data type (kind) including a description.

get_criterion_method() returns information (including the implementing function) about a given method in form of an object of class "criterion_method".

With set_criterion_method() new criterion methods can be added by the user. The implementing function (fun) needs to have the formal arguments x, order, ..., where x is the data object, order is an object of class permutation_vector and ... can contain additional information for the method passed on from criterion(). The implementation has to return the criterion value as a scalar.

Aliases
  • registry_criterion
  • set_criterion_method
  • get_criterion_method
  • list_criterion_methods
  • show_criterion_methods
Examples
## the registry
registry_criterion

## use the convenience functions
list_criterion_methods("dist")

show_criterion_methods("dist")

get_criterion_method("dist", "AR_d")

## define a new method

## a function that return sum of the diagonal elements
criterion_method_matrix_foo <- function(x, order, ...) {
if(!is.null(order)) x <- permute(x,order)
    sum(diag(x))
}

## set new method
set_criterion_method("matrix", "foo", criterion_method_matrix_foo, 
    "foo: a useless demo criterion", FALSE)

list_criterion_methods("matrix")

##use all criterion methods (including the new one)
criterion(matrix(1:9, ncol=3))
Documentation reproduced from package seriation, version 1.2-2, License: GPL-3

Community examples

Looks like there are no examples yet.