Developer Fundamentals — Module 3 of 4
Click to start
“As a developer who has run and logged out-of-the-box tests with ValidMind, I want to update my documentation template to include manually inserted test results, implement, run, and log custom tests, and include those custom tests in my documentation template.”
This third module is part of a four-part series:
Developer Fundamentals
First, let’s make sure you can log in to ValidMind.
Training is interactive — you explore ValidMind live. Try it!
→ , ↓ , SPACE , N — next slide ← , ↑ , P , H — previous slide ? — all keyboard shortcuts
To continue, you need to have been onboarded onto ValidMind Academy with the Developer role and completed the first two modules of this course:
Be sure to return to this page afterwards.
Jupyter Notebook series
When you run these notebooks, they will generate a draft of model documentation and upload it to ValidMind, complete with test supporting test results.
You will need to have already completed notebooks 1 and 2 during the first and second modules to proceed.
Our series of four introductory notebooks for model developers include sample code and how-to information to get you started with ValidMind:
1 — Set up the ValidMind Library
2 — Start the model development process
3 — Integrate custom tests
4 — Finalize testing and documentation
In this third module, we’ll run through the remaining two notebooks 3 in Section 1 and 4 in Section 2 together.
Let’s continue our journey with Section 1 on the next page.
ValidMind generates a unique code snippet for each registered model to connect with your developer environment:
Can’t load the ValidMind Platform?
Make sure you’re logged in and have refreshed the page in a Chromium-based web browser.
Connect to your model
With your code snippet copied to your clipboard:
When you’re done, return to this page and click to continue.
Custom inline tests
Try it live on the next pages.
Let’s implement a custom inline test that calculates the confusion matrix for a binary classification model.
Create a custom test
The @vm.test
wrapper allows you to create a reusable test:
When you’re done, return to this page and click to continue.
Adjust your custom test
Custom tests can take parameters just like any other function:
When you’re done, return to this page and click to continue.
Log your custom test
Use the .log()
method to send the results of your custom test to the ValidMind Platform:
When you’re done, return to this page and click to continue.
Reusable custom tests
Try it live on the next pages.
Creating inline custom tests with a function is a great way to customize your model documentation.
Create custom tests folder
Create a new folder that will contain reusable custom tests from your existing inline tests:
When you’re done, return to this page and click to continue.
Save inline test
The @vm.test
decorator also includes a convenience method that allows you to save the test to a Python file at a specified path:
When you’re done, return to this page and click to continue.
Register local test provider
Next, let’s initialize a test provider that will tell the ValidMind Library where to find your saved custom tests:
When you’re done, return to this page and click to continue.
Custom test results
(Scroll down for the full instructions.)
Try it live on the next page.
With the custom test results logged, let’s head to the model we connected to at the beginning of this notebook and insert our test results into the documentation:
From the Inventory in the ValidMind Platform, go to the model you connected to earlier.
In the left sidebar that appears for your model, click Documentation.
Locate the Data Preparation section and click on 3.2 Model Evaluation to expand that section.
Hover under the Pearson Correlation Matrix content block until a horizontal dashed line with a + button appears, indicating that you can insert a new block.
Click + and then select Test-Driven Block under from library:
ConfusionMatrix
tests you logged above:Finally, click Insert 2 Test Results to Document to add the test results to the documentation.
Confirm that the two individual results for the confusion matrix tests have been correctly inserted into section 3.2 Model Evaluation of the documentation.
4 — Finalize testing and documentation
This is the final notebook in our introductory series, which will walk you through wrapping custom test results into your documentation, as well as how to update the configuration for the entire model documentation template to suit your needs.
Scroll through this notebook to explore. When you are done, click to continue.
As usual, let’s connect back up to your model in the ValidMind Platform:
Connect to your model
With your code snippet copied to your clipboard:
When you’re done, return to this page and click to continue.
Reconnect to ValidMind
After you insert test-driven blocks, changes should persist and become available every time you call the preview_template()
function:
When you’re done, return to this page and click to continue.
Log custom test results
Now that your custom test IDs are part of your template, you can now run tests for an entire section and all additional custom tests will be loaded:
When you’re done, return to this page and click to continue.
get_default_config()
The utility function vm.get_test_suite().get_default_config()
will return the default configuration for the entire documentation template as a dictionary:
run_documentation_tests()
to run all tests in the documentation template if needed.get_default_config()
simply provides a useful reference for providing default parameters to every test.Retrieve default configuration
When you’re done, return to this page and click to continue.
Update template configuration
The default configuration does not assign any inputs to a test, but you can assign inputs to individual tests as needed:
When you’re done, return to this page and click to continue.
Implementing custom tests
In this third module, you learned how to:
Continue your model development journey with:
Finalizing model documentation
ValidMind Academy | Home