Skip to content

Commit b05052c

Browse files
committed
reviewed test_caro and fixed expected result
1 parent a61adb2 commit b05052c

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/test_caro.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,35 @@
4747
value = {temp: 20, tan: 0.55}
4848
result = rules(value)
4949
assert isinstance(result, float)
50-
assert np.isclose(result, -0.5, atol=0.0001)
50+
assert np.isclose(result, 0.45, atol=0.0001)
51+
52+
"""
53+
For the input {temp: 20, tan: 0.55}:
54+
* temp: 20 activates:
55+
temp.mittel (membership = 0.75)
56+
temp.kalt (membership = 0.25)
57+
58+
* tan: 0.55 activates:
59+
tan.mittel (membership = 0.875)
60+
tan.groß (membership = 0.125)
61+
62+
This triggers four rules:
63+
64+
* R4: (temp.kalt, tan.mittel) → gef.klein (firing strength = min(0.25, 0.875) = 0.25)
65+
* R5: (temp.mittel, tan.mittel) → gef.mittel (firing strength = 0.75)
66+
* R7: (temp.kalt, tan.groß) → gef.mittel (firing strength = min(0.25, 0.125) = 0.125)
67+
* R8: (temp.mittel, tan.groß) → gef.groß (firing strength = 0.125)
68+
69+
70+
|------------------|------------------|------------------|
71+
| Rule | Consequent | Weight | Consequent CoG |
72+
|------------------|------------------|------------------|
73+
|R4|gef.klein| 0.25| 0.0 (midpoint of [-0.5, 0.5])
74+
|R5|gef.mittel| 0.75| 0.5 (midpoint of [0, 1])
75+
|R7|gef.mittel| 0.125| 0.5
76+
|R8|gef.groß| 0.125| 1.0 (midpoint of [0.5, 1.5])
77+
78+
COG = (0.25 * 0.0 + 0.75 * 0.5 + 0.125 * 0.5 + 0.125 * 1.0) / (0.25 + 0.75 + 0.125 + 0.125)
79+
= 0.5625/1.25
80+
= 0.45
81+
"""

0 commit comments

Comments
 (0)