# source:orange/docs/reference/rst/code/correspondence.py@9797:7d906669b42d

Revision 9797:7d906669b42d, 990 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Changed data set path.

Line
1# Description: Demonstrates the use of correspondence analysis
2# Category:    correspondence, projection
3# Classes:     CA
4# Uses:        smokers_ct.tab
5import Orange, numpy
6from Orange.projection import correspondence
7from Orange.statistics import contingency
8
9data = Orange.data.Table("smokers_ct.tab")
10staff = data.domain["Staff group"]
11smoking = data.domain["Smoking category"]
12
13# Compute the contingency
14cont = contingency.VarVar(staff, smoking, data)
15
16c = correspondence.CA(cont, staff.values, smoking.values)
17
18print "Row profiles"
19print c.row_profiles()
20print
21print "Column profiles"
22print c.column_profiles()
23
24c.plot_biplot()
25
26print "Singular values: " + str(numpy.diag(c.D))
27print "Eigen values: " + str(numpy.square(numpy.diag(c.D)))
28print "Percentage of Inertia:" + str(c.inertia_of_axes() / sum(c.inertia_of_axes()) * 100.0)
29print
30
31print "Principal row coordinates:"
32print c.row_factors()
33print
34print "Decomposition Of Inertia:"
35print c.column_inertia()
36
37c.plot_scree_diagram()
Note: See TracBrowser for help on using the repository browser.