Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_behavioral.py 1.8 KB

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

Press p or to see the previous file or, n or to see the next file

Comments

Loading...