In trying to test her own ML model, the author ran into a problem typical of Data Science: the documentation exists only in the developer's head, and the dataset readily shows actual values but doesn't answer the question of "how things should be." A minimum in the data doesn't mean an acceptable boundary, and the absence of a feature combination is not the same as its being invalid. Formal criteria are needed for verification. The way out was found in a ready-made Olist model: alongside it was documentation, including feature descriptions, a dataset, saved metrics, and library versions. This made it possible to move from "checking documentation" to implementing a framework. The key idea is to separate the human-readable README from the machine-readable model_metadata.json. The Olist metadata specifies the target "is_late," test metrics, and versions of scikit-learn 1.9.0, pandas 3.0.5, and numpy 2.4.6. Additionally, the framework reads information directly from the loaded model: feature_names_in_, classes_, and the presence of predict and predict_proba. Thus ModelContract was born — a set of requirements assembled from two sources, remembering the origin of each item.
The main value of the approach is that checks are not tied to a specific model. The framework contains only the checking mechanism, while all requirements come from the contract of whichever project is loaded into it. This makes it possible to automate testing of any finished ML models without thinking about the domain. And the combination of metadata and the model's API makes it possible to find discrepancies: for example, if the metadata declares 34 features but feature_names_in_ returns 33, that immediately becomes a concrete FAIL. The plan going forward is to add information about who made a change and when to the report, so you can go straight to the culprit with questions. An example of such a FAIL: "The test dataset has no feature distance_km," requirement from spec v2, item 4.1, change made by @ivanov_dev, PR #142 dated 15.09.2026.
Six months ago, the author had already built an agent for reviewing technical specifications. The new task — ML testing — arose from a practical need: her own project turned out to have no documentation, making it an ideal candidate for the experiment. The absence of formal criteria in her own project led to choosing Olist as the guinea pig, and then to building the framework. It currently implements five checks and is ready to be used on other models.
Source: habr.com · post in Telegram