Add text support for custom test descriptions
validmind-library
2.8.20
documentation
enhancement
highlight
We have enhanced the custom test framework, allowing you to define custom descriptions for your tests. If a test returns a string, it will be used as the test description, overriding the automatic description generation.
@vm.test("my_custom_tests.MyCustomTest")
def my_custom_test(dataset, model):
"""
This is a custom test that does nothing.
"""
= dataset.y
y_true = dataset.y_pred(model)
y_pred
= metrics.confusion_matrix(y_true, y_pred)
confusion_matrix
= metrics.ConfusionMatrixDisplay(
cm_display =confusion_matrix, display_labels=[False, True]
confusion_matrix
)
cm_display.plot()
# close the plot to avoid displaying it
plt.close()
return cm_display.figure_, "Test Description - Confusion Matrix", pd.DataFrame({"Value": [1, 2, 3]})
Run test
from validmind.tests import run_test
= run_test(
result "my_custom_tests.MyCustomTest",
={"model": "model", "dataset": "test_dataset"},
inputs )
Output