# coding survey data for cosine similarity and euclidean distance?

I want to know how to code survey data such that a similarity function can be applied on it.

Say I want to use cosine similarity. All the search results and QA I've found while in my search deal only with the similarity between documents, with vectors consisting of word frequencies or tf/idf.

What about survey data? What is the sensible/common/useful way of coding survey data such that similarity can be compared? (Is it even sensible to use functions like cosine similarity for this?)

My data is record data, purely categorical, neither binary nor numerical. Should I code it into numerical data? My data looks like this (3 sample records):

Do you like Technology?  | Current GPA       | Institute name
Y                        | Band 1 (3.75-4)   | UUIC
N                        | Band 3 (3.0-3.5)  | ADU
N                        | Band 2 (3.5-3.75) | UUIC


etc. These are just 3 questions, my survey had a lot more questions, but I hope you get the idea.

Is it sensible to code the data into numerical vectors, where for eg. I represent yes/no values as binary variables, and assign numbered categories to other values? In which case the above 3 records would become:

(1, 1, 1)
(0, 3, 2)
(0, 2, 1)


Where UUIC = 1, ADU = 2, and the GPA bands are represented simply by 1, 2, 3, 4, etc..

And then apply cosine similarity or euclidean distance? Would this make sense? I've been searching for similar examples for a while now but everything that comes up seems to be about document similarity. There doesn't seem to be much beginner's help on how to deal with survey data.

• BTW your Current GPA variable could be safely considered as interval because you supply the numeric bounds. You might recode it into 1=3.88, 2=3.63, 3=3.25, for example. – ttnphns Oct 31 '13 at 15:18