checkEvalFun: Check a custom performance evaluation function

View source: R/SOptim_CheckOptimFuncParameters.R

checkEvalFunR Documentation

Check a custom performance evaluation function

Description

Checks if a given custom evaluation function, using two vectors (respectively, for observed and predicted values), is able to produce a valid result. See details for more info.

Usage

checkEvalFun(funToTest, nClassType = "undefined", verbose = TRUE)

Arguments

funToTest

A function to test

nClassType

A string defining if the classification is "single-class" or "multi-class"

verbose

Print messages?

Details

To be considered valid the input function for single-class must have:

  • Have at least two inputs arguments;

  • Produce a non-null and valid numerical result;

  • A scalar output;

  • An attribute named 'thresh' defining the numerical threshold to binarize the classifier predictions (i.e., to convert from continuous probability to discrete 0,1).

Valid multi-class functions' must have:

  • Have at least two inputs arguments;

  • Produce a non-null and valid numerical result;

  • A scalar output.

Value

Logical. If TRUE the function is considered valid.

Examples


accMultiClass <- function(obs, pred){
d <- sum(diag(as.matrix(table(obs, pred))))
s <- length(obs)
return(d/s)
}

accMultiClass(1:10, 1:10)

checkEvalFun(funToTest=accMultiClass, nClassType="multi-class", verbose=TRUE)


joaofgoncalves/SegOptim documentation built on Feb. 5, 2024, 11:10 p.m.