# Extract features from a questionnaire

I am using the answers from a questionnaire for a classification problem. I discovered that a question can have nested sub-questions.. Let's say that I want to predict the age of a student based on some question..

i.e. the first question is

1) Did you pass your last exam?
[x] yes
[] no
[] I haven't done it


and a person answers yes. In this case there is a subquestion

1_yes) What was the score?
[x] A
[] B


How should I convert the answers into features to train my model?

Option 1) Treat them separately and transform them with one-hot-encoding I will have then the feature vector

pass_exam_yes - pass_exam_no - pass_exam_not_done - score_empty - score_A - score_B
1    -   0          -     0              -   0         -   1     -   0


Option 2) Merge the 2 answers and encoding the concatenation

pass_exam_yes_A - pass_exam_yes_score_B - pass_exam_no - pass_exam_not_done
1           -              0        -   0          -    0


Other options?

I hope my question was clear enough

• What is your purpose? What does your data represent? The transformations would depend on what do you want to use the data for. – Tim Jul 13 '18 at 9:52
• I am not sure that I understood what you mean... My purpose is to classify the people who answer the questionnaire into classes depending on they answers... what I wrote in the question above is just an example..I think this is a relatively common problem of people working with surveys. The general problem is that some questions are linked to each other and not all the people answer to the same questions because some pop up depending on a previous answer.. – gabboshow Jul 13 '18 at 9:56
• I have edited the question for more clarity – gabboshow Jul 13 '18 at 10:27
• stats.stackexchange.com/questions/118218/… – rolando2 Jul 13 '18 at 14:56