Classification where classes do not use all features?

I am attempting a classification task whereby the features used to describe classes are not all being used. For instance, Class A does not use feature 2, class B does not use feature 4, and class C does not use feature 1 and 2:

f1 | f2 | f3 | f4 | class
10 | NA | 23 | 30 |   A
1  | 11 | 33 | NA |   B
11 | NA | 20 | 32 |   A
NA | NA | 55 | 50 |   C
6  | 9  | 18 | NA |   B
NA | NA | 49 | 45 |   C


One way i have gone about approaching this problem, is converting all NA's to 0's. However, i believe that this would be incorrect. For instance, both class A and Class C both do not utilize feature 2, and if we assign all values to 0 in that feature space, we will be incorrectly attempting to distinguish between class A and class C, when there is nothing to distinguish in the first place. Imputing values for those features is not an option here.(ie., The data isnt missing per se, its just not possible for class A to have feature 2)

If i go ahead and input the dataset as is, with the NA values still inside, i end up with the following error when using a Naive Bayes classifier from the naivebayes package in R:

Error in density.default(x, na.rm = TRUE, ...): need at least 2 points to select a bandwidth automatically


How should i go about dealing with this problem correctly?

• What prompted collection of these data? What is your null hypothesis? Because you know some classes have unused categories, you know probabilities of categories can't be the same across classes. Commented Jan 14, 2019 at 8:33
• What are you trying to achieve? If you want to classify, then the NAs are very useful: If feature 2 is NA, then the class is either A or C, but definitely not B. If you don't have too many combinations, you can cut your dataset into chunks: collect everything where feature 2 is NA and classify this into A or C using the remaining (non-NA) features. Commented Jan 14, 2019 at 8:56
• Hi, just to clarify that the example of class A,B and C is a hypothetical one. Unfortunately, I will eventually be dealing with possibly several hundreds of classes for a product i am developing, so yes there will be many combinations @StephanKolassa . As such, while developing my algorithm, I am working on smaller representative datasets such as the example given above. Commented Jan 14, 2019 at 9:08
• OK. It mainly sounds like you have a classification task with "much" missing data, is that correct? Do previous questions with these tags help? Specifically Binary classification when many binary features are missing? Commented Jan 14, 2019 at 9:13
• Yes, you are absolutely correct @BruceET. Would you be able to refer me to some literature or an algorithm that deals with classification with uneven class probabilities/ unused categories? Commented Jan 14, 2019 at 9:13