Robustness is the ability of a closed-loop system to tolerate perturbations or anomalies while system parameters are varied over a wide range. There are three essential tests to ensure that the machine learning system is robust in the production environments: unit testing, data and model testing, and integration testing.
Unit testing
Tests are performed on individual components that each have a single function within the bigger system (for example, a function that creates a new feature, a column in a DataFrame, or a function that adds two numbers). We can perform unit tests on individual functions or components; a recommended method for performing unit tests is the Arrange, Act, Assert (AAA) approach:
1. Arrange: Set up the schema, create object instances, and create test data/inputs.
2. Act: Execute code, call methods, set properties, and apply inputs to the components to test.
3. Assert: Check the results, validate (confirm that the outputs received are as expected), and clean (test-related remains).
Data and model testing
It is important to test the integrity of the data and models in operation. Tests can be performed in the MLOps pipeline to validate the integrity of data and the model robustness for training and inference. The following are some general tests that can be performed to validate the integrity of data and the robustness of the models:
1. Data testing: The integrity of the test data can be checked by inspecting the following five factors—accuracy, completeness, consistency, relevance, and timeliness. Some important aspects to consider when ingesting or exporting data for model training and inference include the following:
• Rows and columns: Check rows and columns to ensure no missing values or incorrect patterns are found.
• Individual values: Check individual values if they fall within the range or have missing values to ensure the correctness of the data.
• Aggregated values: Check statistical aggregations for columns or groups within the data to understand the correspondence, coherence, and accuracy of the data.
2. Model testing: The model should be tested both during training and after it has been trained to ensure that it is robust, scalable, and secure. The following are some aspects of model testing:
• Check the shape of the model input (for the serialized or non-serialized model).
• Check the shape and output of the model.
• Behavioral testing (combinations of inputs and expected outputs).
• Load serialized or packaged model artifacts into memory and deployment targets. This will ensure that the model is de-serialized properly and is ready to be served in the memory and deployment targets.
• Evaluate the accuracy or key metrics of the ML model.
Integration testing
Integration testing is a process where individual software components are combined and tested as a group (for example, data processing or inference or CI/CD).
0 comments:
Post a Comment