Subject multidimensional data

I have records of club members and their interests, as follows:

Member A: Football, Swimming
Member B: Swimming, Jooga, Jogging
Member C: Cycling, Football
Member D: Football, Tennis, Cycling

Is it possible to build them in Python so that you can see how the different participating participants share each other? Thanks in advance Adia

+5
source share
2 answers

A simple table seems to make more sense than a Venn diagram:

import scipy, pylab
names = ['Alice', 'Bob', 'Carol', 'David']
interests = [['Football', 'Swimming'], ['Swimming', 'Jooga', 'Jogging'], 
             ['Cycling', 'Football'], ['Football', 'Tennis', 'Cycling']]
allinterests = list(set(reduce(lambda x,y:x+y, interests)))
X = scipy.zeros((len(interests), len(allinterests)))
for i, indinterests in enumerate(interests):
    for x in indinterests:
        X[i, allinterests.index(x)] = 1
pylab.matshow(X, interpolation='nearest', cmap=pylab.cm.gray_r)
pylab.show()
pylab.yticks(range(len(names)), names)
pylab.ylim([len(names)-0.5, -0.5])
pylab.xticks(range(len(allinterests)), allinterests)
pylab.savefig('interests.png')

alt text

+6
source

You might want to take a look at matplotlib and see if it offers something suitable for this.

Sage is another alternative. See also this example .

+3
source

All Articles