1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
- import pytest
- import utils
- @pytest.mark.parametrize(
- "input_a, input_b, label",
- [
- (
- "Transformers applied to NLP have revolutionized machine learning.",
- "Transformers applied to NLP have disrupted machine learning.",
- "natural-language-processing",
- ),
- ],
- )
- def test_invariance(input_a, input_b, label, predictor):
- """INVariance via verb injection (changes should not affect outputs)."""
- label_a = utils.get_label(text=input_a, predictor=predictor)
- label_b = utils.get_label(text=input_b, predictor=predictor)
- assert label_a == label_b == label
- @pytest.mark.parametrize(
- "input, label",
- [
- (
- "ML applied to text classification.",
- "natural-language-processing",
- ),
- (
- "ML applied to image classification.",
- "computer-vision",
- ),
- (
- "CNNs for text classification.",
- "natural-language-processing",
- ),
- ],
- )
- def test_directional(input, label, predictor):
- """DIRectional expectations (changes with known outputs)."""
- prediction = utils.get_label(text=input, predictor=predictor)
- assert label == prediction
- @pytest.mark.parametrize(
- "input, label",
- [
- (
- "Natural language processing is the next big wave in machine learning.",
- "natural-language-processing",
- ),
- (
- "MLOps is the next big wave in machine learning.",
- "mlops",
- ),
- (
- "This is about graph neural networks.",
- "other",
- ),
- ],
- )
- def test_mft(input, label, predictor):
- """Minimum Functionality Tests (simple input/output pairs)."""
- prediction = utils.get_label(text=input, predictor=predictor)
- assert label == prediction
|