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.
"""
y_true = dataset.y
y_pred = dataset.y_pred(model)
confusion_matrix = metrics.confusion_matrix(y_true, y_pred)
cm_display = metrics.ConfusionMatrixDisplay(
confusion_matrix=confusion_matrix, display_labels=[False, True]
)
cm_display.plot()
plt.close() # close the plot to avoid displaying it
return cm_display.figure_, "Test Description - Confusion Matrix", pd.DataFrame({"Value": [1, 2, 3]})Run test
from validmind.tests import run_test
result = run_test(
"my_custom_tests.MyCustomTest",
inputs={"model": "model", "dataset": "test_dataset"},
)Output
