View source: R/SOptim_CheckOptimFuncParameters.R
checkEvalFun | R Documentation |
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.
checkEvalFun(funToTest, nClassType = "undefined", verbose = TRUE)
funToTest |
A function to test |
nClassType |
A string defining if the classification is |
verbose |
Print messages? |
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.
Logical. If TRUE
the function is considered valid.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.