register_custom_test | R Documentation |
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.
register_custom_test(
func,
test_id = NULL,
description = NULL,
required_inputs = NULL
)
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 |
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.
The test store object containing the newly registered custom test.
r_to_py
, import_main
, py_run_string
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.