register_custom_test {validmind} | R Documentation |
Register a Custom Test Function in ValidMind
Description
Registers an R function as a custom test within the ValidMind testing framework, allowing it to be used as a custom metric for model validation.
Usage
register_custom_test(
func,
test_id = NULL,
description = NULL,
required_inputs = NULL
)
Arguments
func |
An R function to be registered as a custom test. |
test_id |
A unique identifier for the test. If |
description |
A description of the test. If |
required_inputs |
A character vector specifying the required inputs for the test. If |
Details
The provided R function is converted into a Python callable using r_to_py
.
A Python class is then defined, inheriting from ValidMind's Metric
class, which wraps this callable.
This custom test is registered within ValidMind's test store and can be used in the framework for model validation purposes.
Value
The test store object containing the newly registered custom test.
See Also
r_to_py
, import_main
, py_run_string
Examples
## Not run:
# Define a custom test function in R
my_custom_metric <- function(predictions, targets) {
# Custom metric logic
mean(abs(predictions - targets))
}
# Register the custom test
register_custom_test(
func = my_custom_metric,
test_id = "custom.mae",
description = "Custom Mean Absolute Error",
required_inputs = c("predictions", "targets")
)
## End(Not run)