Extracting features from categorical variables