Line | |
---|

1 | # Description: Shows what the contingency matrix looks like and which are its common methods |
---|

2 | # Category: statistics |
---|

3 | # Classes: Contingency, ContingencyAttrClass |
---|

4 | # Uses: monk1 |
---|

5 | # Referenced: contingency.htm |
---|

6 | |
---|

7 | import orange |
---|

8 | data = orange.ExampleTable("monk1") |
---|

9 | cont = orange.ContingencyAttrClass("e", data) |
---|

10 | |
---|

11 | print "Contingency items:" |
---|

12 | for val, dist in cont.items(): |
---|

13 | print val, dist |
---|

14 | print |
---|

15 | |
---|

16 | print "Contingency keys: ", cont.keys() |
---|

17 | print "Contingency values: ", cont.values() |
---|

18 | print "Contingency items: ", cont.items() |
---|

19 | print |
---|

20 | |
---|

21 | print "cont[0] =",cont[0] |
---|

22 | print 'cont[\"1\"] =', cont["1"] |
---|

23 | print 'cont[orange.Value(data.domain["e"], "1")] =', cont[orange.Value(data.domain["e"], "1")] |
---|

24 | print |
---|

25 | |
---|

26 | print "Iteration through contingency:" |
---|

27 | for i in cont: |
---|

28 | print i |
---|

29 | print |
---|

30 | |
---|

31 | cont.normalize() |
---|

32 | print "Contingency items after normalization:" |
---|

33 | for val, dist in cont.items(): |
---|

34 | print val, dist |
---|

35 | print |
---|

**Note:** See

TracBrowser
for help on using the repository browser.