94 sao GitHub và vẫn tăng — GokuMohandas/testing-ml là dự án Jupyter Notebook mà TopGit đang theo dõi trên nền tảng. Learn how to create reliable ML systems by testing code, data and models.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Learn how to create reliable ML systems by testing code, data and models.
👉 This repository contains the interactive notebook that complements the testing lesson, which is a part of the MLOps course. If you haven't already, be sure to check out the lesson because all the concepts are covered extensively and tied to software engineering best practices for building ML systems.
Data
Expectations
Production
Models
Training
Behavioral
Adversarial
Inference
Data
Tools such as pytest allow us to test the functions that interact with our data but not the validity of the data itself. We're going to use the great expectations library to create expectations as to what our data should look like in a standardized way.
!pip install great-expectations==0.15.15 -q
import great_expectations as ge
import json
import pandas as pd
from urllib.request import urlopen
A curated list of Monte Carlo tree search papers...
reinforcement-learning
4
19
2020-03-03 13:54:31
Diffusion to Vector
Reference implementation of Diffusion2Vec (Com...
graph-learning
Expectations
When it comes to creating expectations as to what our data should look like, we want to think about our entire dataset and all the features (columns) within it.
# Presence of specific features
df.expect_table_columns_to_match_ordered_list(
column_list=["id", "created_on", "title", "description", "tag"]
)
# Unique combinations of features (detect data leaks!)
df.expect_compound_columns_to_be_unique(column_list=["title", "description"])
# Type adherence
df.expect_column_values_to_be_of_type(column="title", type_="str")
# List (categorical) / range (continuous) of allowed values
tags = ["computer-vision", "graph-learning", "reinforcement-learning",
"natural-language-processing", "mlops", "time-series"]
df.expect_column_values_to_be_in_set(column="tag", value_set=tags)
There are just a few of the different expectations that we can create. Be sure to explore all the expectations, including custom expectations. Here are some other popular expectations that don't pertain to our specific dataset but are widely applicable:
feature value relationships with other feature values → expect_column_pair_values_a_to_be_greater_than_b
row count (exact or range) of samples → expect_table_row_count_to_be_between
The advantage of using a library such as great expectations, as opposed to isolated assert statements is that we can:
reduce redundant efforts for creating tests across data modalities
automatically create testing checkpoints to execute as our dataset grows
automatically generate documentation on expectations and report on runs
easily connect with backend data sources such as local file systems, S3, databases, etc.
# Run all tests on our DataFrame at once
expectation_suite = df.get_expectation_suite(discard_failed_expectations=False)
df.validate(expectation_suite=expectation_suite, only_return_failures=True)
Many of these expectations will be executed when the data is extracted, loaded and transformed during our DataOps workflows. Typically, the data will be extracted from a source (database, API, etc.) and loaded into a data system (ex. data warehouse) before being transformed there (ex. using dbt) for downstream applications. Throughout these tasks, Great Expectations checkpoint validations can be run to ensure the validity of the data and the changes applied to it.
Models
Once we've tested our data, we can use it for downstream applications such as training machine learning models. It's important that we also test these model artifacts to ensure reliable behavior in our application.
Training
Unlike traditional software, ML models can run to completion without throwing any exceptions / errors but can produce incorrect systems. We want to catch errors quickly to save on time and compute.
Behavioral testing is the process of testing input data and expected outputs while treating the model as a black box (model agnostic evaluation). A landmark paper on this topic is Beyond Accuracy: Behavioral Testing of NLP Models with CheckList which breaks down behavioral testing into three types of tests:
invariance: Changes should not affect outputs.
# INVariance via verb injection (changes should not affect outputs)
tokens = ["revolutionized", "disrupted"]
texts = [f"Transformers applied to NLP have {token} the ML field." for token in tokens]
predict.predict(texts=texts, artifacts=artifacts)
# DIRectional expectations (changes with known outputs)
tokens = ["text classification", "image classification"]
texts = [f"ML applied to {token}." for token in tokens]
predict.predict(texts=texts, artifacts=artifacts)
minimum functionality: Simple combination of inputs and expected outputs.
# Minimum Functionality Tests (simple input/output pairs)
tokens = ["natural language processing", "mlops"]
texts = [f"{token} is the next big wave in machine learning." for token in tokens]
predict.predict(texts=texts, artifacts=artifacts)
['natural-language-processing', 'mlops']
Adversarial
Behavioral testing can be extended to adversarial testing where we test to see how the model would perform under edge cases, bias, noise, etc.
texts = [
"CNNs for text classification.", # CNNs are typically seen in computer-vision projects
"This should not produce any relevant topics." # should predict `other` label
]
predict.predict(texts=texts, artifacts=artifacts)
['natural-language-processing', 'other']
Inference
When our model is deployed, most users will be using it for inference (directly / indirectly), so it's very important that we test all aspects of it.
Loading artifacts
This is the first time we're not loading our components from in-memory so we want to ensure that the required artifacts (model weights, encoders, config, etc.) are all able to be loaded.
Once we have our artifacts loaded, we're readying to test our prediction pipelines. We should test samples with just one input, as well as a batch of inputs (ex. padding can have unintended consequences sometimes).
# test our API call directly
data = {
"texts": [
{"text": "Transfer learning with transformers for text classification."},
{"text": "Generative adversarial networks in both PyTorch and TensorFlow."},
]
}
response = client.post("/predict", json=data)
assert response.status_code == HTTPStatus.OK
assert response.request.method == "POST"
assert len(response.json()["data"]["predictions"]) == len(data["texts"])
...
Learn more
While these are the foundational concepts for testing ML systems, there are a lot of software best practices for testing that we cannot show in an isolated repository. Learn a lot more about comprehensively testing code, data and models for ML systems in our testing lesson.
GokuMohandas/testing-ml thuộc nhóm AI Tools trên TopGit, cùng 5 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về GokuMohandas/testing-ml ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/GokuMohandas/testing-ml là nguồn chính thức.
GokuMohandas/testing-ml có bao nhiêu sao?
GokuMohandas/testing-ml có 94 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/GokuMohandas/testing-ml. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
GokuMohandas/testing-ml có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho GokuMohandas/testing-ml. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
GokuMohandas/testing-ml có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho GokuMohandas/testing-ml. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
GokuMohandas/testing-ml là gì?
GokuMohandas/testing-ml (GokuMohandas/testing-ml) là dự án Jupyter Notebook trên GitHub. Theo mô tả gốc: Learn how to create reliable ML systems by testing code, data and models.
GokuMohandas/testing-ml so với các dự án AI Tools khác thế nào?
GokuMohandas/testing-ml được TopGit xếp vào nhóm AI Tools, với 94 sao GitHub và viết bằng Jupyter Notebook. Xem trang chủ đề AI Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về testing-ml?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về testing-ml.