Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 202012

Accessing variables in e1071 for custom error.fun

$
0
0

I am trying to write a function that calculates F1 so I can use F1 as the error.fun in tune.svm using the e1071 library. I have found the underlying code:

                repeat.errors[reps] <- if (!is.null(tunecontrol$error.fun))
                    tunecontrol$error.fun(true.y, pred)
                else if ((is.logical(true.y) || is.factor(true.y)) && (is.logical(pred) || is.factor(pred) || is.character(pred))) ## classification error
                    1 - classAgreement(table(pred, true.y))
                else if (is.numeric(true.y) && is.numeric(pred)) ## mean squared error
                    crossprod(pred - true.y) / length(pred)
                else
                    stop("Dependent variable has wrong type!")

at: https://github.com/cran/e1071/blob/master/R/tune.R

I would like to access the variables for predictions for individual folds. I think these are stored in the vectors true.y and pred in the above code but I cannot figure out how to #1)View those vectors so I can see if the actually contain the values I need and #2)Use those values in my function.

I have tried: toString(true.y) toString(pred) print(true.y) print(pred)

but none of that works. How can I access these variables?


Viewing all articles
Browse latest Browse all 202012

Trending Articles