Using the UCI dataset here: http://archive.ics.uci.edu/ml/datasets/Congressional+Voting+Records

Each congressperson votes yay, nay or present (basically abstains) on 16 issues. My teacher wants us to treat missing values (vote present) as a third category. So I thought of making a new column for each vote. So columns for votes 1 to 16 are either 1 for yay or 0 for nay and no value or NaN for abstaining. Then the new 16 columns called abstention are either 1 if the corresponding vote column was a NaN or no value and 0 otherwise. We can use up to 3 items to find some associations.

Is the above correct method to create a third category? Then when I search associations using Python apyori or R, do I include 3 pairs of (vote, abstention)?


1 Answer 1


No, given your teacher's request, you should not record abstain votes as missing values, but rather as a distinct third category. So for every question you have a factor variable with three levels. Otherwise many routines would just ignore the abstain votes instead of including them in the calculations.

  • $\begingroup$ oh, I see so for association rules I need to binarize so there would be six classes. is yay, is not yay, is nay, is not nay, is abstain, is not abstain? $\endgroup$ Mar 13, 2020 at 17:45
  • $\begingroup$ actually three would do, is yay, is nay, is abstain $\endgroup$ Mar 13, 2020 at 17:49
  • 1
    $\begingroup$ Yes, three dummy variables will do. There is a handy function for this in Python: pandas.get_dummies(). $\endgroup$
    – Arne
    Mar 13, 2020 at 22:19
  • $\begingroup$ haha, I spent so much time making the dummy variables manually before seeing this. And I didn't even do it right. $\endgroup$ Mar 27, 2020 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.